Setting up Zend Framework from A to Z Step 1
The main problem with Zend Framework that there is no centralized documentation how to actually set up the framework to use with web applications. There is documentation for the different components and a primitive introduction on the recommended file structure and how to set up the front controller. So my aim is to write a generalized framework setup tutorial. Still learning the framework, I will write down each step to set up a web application.
Step 1:
I’m guessing you already downloaded Zend Framework from their website. Installing it is straightforward, although there are different methods/preferences. I prefer to use a centralized location where the framework is available to all of my projects and not to copy the scripts in each project directory. This makes updating the framework very easy.
When you download the archive file you find a library directory in it. That’s what we’re interrested in,the rest are unit tests, demos, etc.
Simply choose a directory outside your projects directory. For ex. my projects directory is server/www/ also my php and apache folders are in server/php/ and server/apache/. So logically I chose server/frameworks/ for my frameworks directory (I use other frameworks too). I created server/frameworks/zend/ and copy it the library directory, it looks like: server/frameworks/zend/library/ the path to the actual script files is server/frameworks/zend/library/Zend/ which you can find in the library folder.
Next I edited my PHP include_path in the php.ini file. I added this path “Server/frameworks/zend/library; …”
OK. The framework is set up. Now we have to create a project.
Step 2
Let’s say the project is called my_project. I like to set up a virtual directory for each project I create. So I edited httpd.conf file in my apache/conf folder.
This is a basic setup for the general projects folder:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName 127.0.0.1
ServerAlias localhost
DocumentRoot “Server/www”
</VirtualHost>
And this is for the my_project (assuming the directory is server/www/my_project)
<VirtualHost *:80>
ServerName my_project
DocumentRoot “Server/www/my_project/public”
DirectoryIndex index.php
<Directory “Server/www/my_project/public”>
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Note that my_project/public is the only directory available from the Internet. This I will write in detail in the next post.
Note. I use windows xp as my main development OS. So i have to insert a new route in c:\windows\system32\drivers\etc\hosts file. I inserted a new line: 127.0.0.1 my_project
So when I type in the browser’s address bar http://my_project then it routes to server/www/my_project/ folder and from there (because of the apache DocumentRoot set up earlier) to public folder.
I will be continuing this post very very soon. Until then enjoy.


Comments
July 7th, 2008
hey… pls continue this post and notify.
i’m new in php, i’ve been hearing this zend framework can u make tutorials of this from setting up to execution. a dummy way
ps. can u create a pdf of ur tutorials if u continue
September 3rd, 2008
good post, thanks
September 13th, 2008
Keep goin on the zend framework bro. I have one set up as per tutorials on nonzend sites. It’s a standard MVC setup, all the guts of it lie one level back from the doc root and you have to write a dispatcher to get them. They do a lot of work for you but they don’t just give you an out of the box setup. It is more flexible this way. but a learning curve.
November 18th, 2008
It’s awesome for the beginners in zend framework.Can u please refer some examples for us to begin in zend. Would be pleased to get further helps from u.
December 30th, 2008
Great post. But can you also specify a secure way to install zend
framework on a server where you don’t have access to apache config
and you can’t go further than root folder. Thanks
February 25th, 2009
Hi Thanks for your valuable contibution with us. I am working with cakePHP and i have changed the . Now it possible to write other directory path for zend framework. With warm regards Umesh
September 2nd, 2009
Hey, Nice post you have here….really helped me in setting up my zend framework.But please can you continue?