Getting started with Zend on XAMPP
Today I am going to show you how to set up the Zend framework using XAMPP on a Mac.
First step is to download the Zend Framework. You can do this by going to the official website:
Unzip the the file and rename to ‘zend’, though the folder name doesn’t really matter. Finally copy the folder to /Applications/ XAMPP/ htdocs/.
Include the Zend Framework
Next we need to tell PHP where to find the Zend Library. We do this by editing the PHP.ini file which is located in /Applications/ XAMPP/ etc/ php.ini. Right at the bottom of the file you can see where the pear library has been added:
;***** Added by go-pear include_path=".:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear"
Replace the above with the following:
Alternatively, you can add the following php code in ‘public/index.php‘..
Now restart Apache so the changes take effect!
Note: Some versions of XAMPP may already include the Zend library (/Applications/ XAMPP/ xamppfiles/ lib/ php/ pear/ Zend)!
Using Zend Tool
A cool thing about Zend is the ability to use Zend commands in terminal. To install Zend Tool simply open up the terminal or iTerm in my case and type the following:
To check to see if the alias worked simply type:
zf show version
My iTerm prints out: Zend Framework Version: 1.11.11
Creating a Project
Zend Tool makes it really easy to create a new project. In the terminal window simply type:
zf create project /Applications/XAMPP/htdocs/mynewproject
Now if you navigate to the htdocs in XAMMP, you will see that Zend Tool has created a new project called ‘mynewproject’. Pretty cool huh? There are loads of other cool commands for Zend Tool such as zf create controller, zf enable layout etc.. To find out more simply type zf in the terminal window.
When developing our application, we want to ensure Zend displays all errors when they occur. To do this open up the following file:
/Applications/ XAMPP/ htdocs/ robszend/ public/ .htaccess
Right at the top of the file add the following line of code:
SetEnv APPLICATION_ENV development
This will set the Environment variable to ‘development‘. You can view all the possible modes by going to:
/Applications/ XAMPP/ xamppfiles/ htdocs/ robszend/ application/ configs/ application.ini
Just be sure to set the Environment variable to production once you set the site / application live.
SetEnv APPLICATION_ENV production