Basic AJAX Example for Zend Framework

 This app example based on a prior Zend QuickStart tutorial design andis for those who want an EASY AJAX example to get a Zend jump start.Or want help installing Zend on WAMP... All files are in the download.The source samples follow the install text. All source should all beplatform independent: Linux, Windows, Mac, or anywhere you can run ZF.But this test configuration is Windows/WampServer just for reference.Easy install instructions (or how I use this app anyway):1) download and install Zend Framework by putting the Zend folder in a server directory path (mine is wamp\www). I renamed the current lib folder to 'Zend' just to keep it simple. And the full or minimal package works here, but only min is needed for this basic example.2) add either an include path for the \Zend\library... folder as they indicate, or copy the \Zend\library\Zend folder into the same library folder with this application. The include path set in the index.php start-up file should find either one. This is what I added to my server's php.ini just for reference: include_path = ".;c:\wamp\www\zend\library" (not the php.ini in the php directory, if you edit this manually)3) install this app folder in the server path. (I put it in ..\Zend also).4) start/re-start your test server.5) then run a URL something like this in your browser: http://localhost/Zend/BasicAjax/index.phpYes, you can use simpler URL's with server conf changes but that's up to you.But .htaccess files are not needed with this.Here is the default directory structure I use:\wamp\www\Zend\BasicAjax...then: ..\application ..\controllers ..\layouts ..\models ..\views ..\data ..\php ..\text ..\xml ..\library (basically empty, where the Zend folder goes if needed) ..\public ..\css ..\jsThis works but I might move the shared files and libs to a more common arealater on.(Follow up: XAMPP is easier to get up and running. For Windows, just copy the examples here into \xampp\htdocs then make any local changes you need. But be sure to change the include path in \xampp\php\php.ini if you update the Zend Library source -- and it should be first because there is another version of Zend in the PEAR folder. It should look something like this: include_path = ".;C:\xampp\htdocs\Zend\library;C:\xampp\php\PEAR" For Linux/LAMPP and Zend, the easiest install (at least on the popular Ubuntu) is to run sudo apt-get install zend-framework-bin in a terminal window, then add the Zend path to set_include_path, as in the index.php file below. For more on this see my Zend/XAMPP install page)And just a simple example here, but hope it helps. Best of luck.This software provided "AS IS," but is FREE to use and share.For details see the Creative Commons license.Download Basic Ajax for Zend Framework here...
View simple example Zend website with this design...
Here are some source samples of what is included. The index is in a Zend Framework
design of course with my simpler directory and include changes plus a bit more.
The DEFINEs carry through to the app content.

The bootstrap file is similar to the Quick Start design but has only what this app needs.
Modified APPLICATION_PATH still needed for the Zend Framework library...

Mostly a thin controller design here but includes an example of a controller fetch
that displays AJAX modelled data on start-up.

The model contains the AJAX library call and is generic enough to work with various
JavaScript AJAX frameworks and libraries. Simple routine just a working example.

For your convenience, here are links to popular JS AJAX Lib downloads:
 [Prototype Library] [jQuery Library] [Dojo Library]
The layout has the static page information: header, footer plus content
as demonstrated in the Quick Start. I customized it from there.

The view page in this example has the user interaction features.
Content combines with the layout gives you a flexible AJAX ZF design.
This should be apparent when you run the example.

This is just one example of how you can integrate JavaScript AJAX with Zend Framework
but I hope this gives you an idea about what MVC and Zend Framework can do for you
even with just basic AJAX stirred in... A few sample data files are in the download with
the complete example source, CSS, and the install text at the top of this page. And IE6
or newer browsers should be compatible here.
Browsers tested (current versions): MS Internet Explorer, Firefox, Opera, Chrome, and Safari.
If Zend with PHP cURL instead of AJAX is what you want, try the BasiccURL example.
Note that PHP cURL has easy Back and Forward browser button support.

All of these basic source examples were tested with Zend Framework release 1.1n.n.
also, the recently updated Zend Framework Quick Start page.
and if any Quickstart problems, see tips on my XAMPP or WAMP install pages.
Note: If you need XSLT with Google Chrome or Safari, try my PHP workaround...
And if you just need a simple AJAX routine try this...

Food for thought: whatever is most compatible, runs fastest, and is the easiest
to maintain is often the 'right way' to do things.
Download Basic Ajax for Zend Framework here.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章