Green Acorn

Blog

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.

Download Zend

First step is to download the Zend Framework. You can do this by going to the official website:

http://www.zend.com/community/downloads

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:

include_path=".:/Applications/XAMPP/xamppfiles/lib/php:/Applications/XAMPP/xamppfiles/lib/php/pear:/Applications/XAMPP/htdocs/zend/library"

Alternatively, you can add the following php code in ‘public/index.php‘..

set_include_path(dirname(__FILE__).PATH_SEPARATOR.'/Applications/XAMPP/htdocs/zend/library');

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:

alias zf=/Applications/XAMPP/htdocs/zend/bin/zf.sh

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.

Development Mode

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

The next stage would be to set up the vhosts – but I’ve already blogged about this, so you can read about it here. I hope you found this web development tutorial useful.

Author:
Posted in: PHP, Zend

Leave a Reply

Your email address will not be published. Required fields are marked *

     

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>