* Aja · My · Ajax *

Basic cURL Example for Zend Framework from AjaMyAjax...


This app example based on a prior Zend QuickStart tutorial design and
is for those who want an EASY cURL 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 be
platform 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/BasiccURL/index.php

Yes, 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\BasiccURL...
then:
   ..\application
      ..\controllers
      ..\layouts
      ..\models
      ..\views
   ..\data
      ..\php
      ..\text
      ..\xml
   ..\library (basically empty, where the Zend folder goes if needed)
   ..\public
      ..\css
      ..\cURL

This works but I might move the shared files and libs to a more common area
later 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 --
 for instance, you might need to change the localhost path in index.php.
 Just be sure to enable the php curl library by uncommenting this line:
 ;extension=php_curl.dll which is found in \XAMPP\php, then restart.

 Also 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)
 
 Remember to install the php cURL lib with apt-get install curl php5-curl
 or similar command in terminal, if necessary (in this case for Debian-based Ubuntu)
 but only if you are using the Apache server outside of XAMPP.

And just another simple ZF example here, but hope it helps.  Best of luck.

Mark Omohundro, AjaMyAjax.com

This software provided "AS IS," but is FREE to use and share. For details see the Creative Commons license: http://creativecommons.org/licenses/by-sa/3.0/
Download Basic cURL for Zend Framework here...



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.
APPLICATION_PATH needed again for the Zend Framework library...



More of a fat controller design that includes simple and custom calls that displays
specific files using only PHP cURL. And XML, XSL support is built into the cURL Lib.



This model contains only the basic or multi-purpose cURL library call.



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 cURL ZF design.
This should be apparent when you run the example.



I hope that gives you more info about what MVC and Zend Framework can do for you
with custom PHP cURL routines added. 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.

(Note: PHP cURL can be used in an AJAX way to load files, but it cannot update innerHTML...
 So if you want to refresh page data in place, you will need AJAX for its XMLHttpRequest.)

If Zend with JavaScript AJAX is what you need instead, try the BasicAjax example...

Download Basic cURL for Zend Framework here...

All of these basic source examples were tested with Zend Framework release 1.10.x...
but note the Zend autoloader routine has changed from previous versions...

and this might need to be updated for the current ZF Quick Start example also.
and if any Quickstart problems, see my tips on XAMPP or WAMP install pages...

Browsers tested (current versions): MS Internet Explorer, Firefox, Opera, Chrome, and Safari.

More tips plus other PHP, JavaScript, AJAX library source can be accessed at AjaMyAjax...
(where you can get free example code that actually works)....

Also have you tried free, fast, easy-to-use Ubuntu Linux yet, Windows($) users???
Get it here: Ubuntu download page
...
"Why Ubuntu Linux is better than Windows"
(or IMO at least worth trying before paying for your next O/S upgrade*)

* Easy to install and supports more devices than you might think
* Several current versions available from server to cool graphics and low memory U/I
* Fast booting after install, even on old computers with little memory
* Can coexist with Windows (if necessary) and be trial run on boot CD or DVD
* More secure operating system by design with practically no viruses
* Various customizable user interfaces to suit your preferences and your hardware
* Easy app software upgrade and maintenance utilities with graphical interfaces
* Many free add-on packages include office tools, available with one-click installation
* Popular browsers such as FireFox, Opera, and even Google Chrome are now available
* Smart user community with plenty of internet support available
* And best of all, Ubuntu is free!