Setting up a new Zend Framework Application
When setting up a Zend Framework application, there are a few basic steps to follow. This post will explain to you how to configure the paths and bootstrap to get going and use Zend_Tool to generate your project files.
It all starts with a download...
You will need Zend Framework 1.8.1 to fully harnass the power of the application code. You can download the latest version of Zend Framework on following url:
http://framework.zend.com/download/current/
Take the full package (we might need dojo later, not sure yet how far I'll take the series :)) and expand it.
Set up your project directory and paths
Create a new directory for your project, mine is: /var/www/apptest. Copy the library and bin directory from the Zend Framework package into this dir. You might actually copy the files in the bin directory somewhere else in your PATH, but I've decided to keep it in my project. this means I have to add the bin directory to the path. Since I want it there everytime I log in, I've put it in my ~/.profile file (I'm on debian, it might be named otherwise on other systems, e.g. ~/.bash_profile on Red Hat):
PATH=$PATH:$HOME/bin:/var/www/apptest/bin ZEND_TOOL_INCLUDE_PATH=/var/www/apptest/library export PATH export ZEND_TOOL_INCLUDE_PATH
The $ZEND_TOOL_INCLUDE_PATH environment variable will be used by the zf.php script to determine where to find your Zend library.
Be sure to execute the profile script or relogin so it takes effect:
. ~/.profile
Create an extra directory /var/www/apptest/logs which will hold our log files aswell as those from apache.
Set up your project
You set up your project with one simple command:
zf.sh create project /var/www/apptest
Set up your virtual host
Next, I created a new virtual host for my project:
<VirtualHost *:80>
DocumentRoot "/var/www/apptest/public/"
ServerName apptest
ServerAlias apptest.test
ErrorLog "/var/www/apptest/logs/apache_error_log"
CustomLog "/var/www/apptest/logs/apache_access_log" "%h %l %u %t \"%r\" %>s %b %D"
RewriteEngine Off
<Directory "/var/www/apptest/public/">
Options Indexes FollowSymLinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>
<Location />
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</Location>
SetEnv APPLICATION_ENV development
</VirtualHost>
Almost done... now we restart our apache.
And for the cherry on the cake...
Ok, great so far, but you won't be able to access the site unless you add it to your hosts file.
I'm on mac, so I changed my hosts file with "sudo nano /etc/hosts" which you can probably also use on linux or any other good system. If you're on windows, you can have a look at c:\windows\system32\drivers\etc (more info here).
You basically add the IP of your server and the hostname (the ServerAlias you specified in your hosts file).
When you open the site in your browser, you should see the Zend Framework Welcome page!






+32 475 62.42.64