Installing Zend Framework on MAMP
As usual, I’m sharing a solution a problem that I personally encountered and couldn’t find a great solution for. So I’ve been using my laptop more and more as my local development environment in order to keep things private and secure while in the dev stage. Among learning how to fully utilize SVN locally, I’ve been trying to setup my laptop to be a fully functional server while also being extremely easy to maintain and change my environment on the fly. To do this, I’m running MAMP (Mac Apache MySQL PHP) available for free at mamp.info as well as the Zend Framework bundled with Zend Tool.
- Get MAMP up and running, no special setup is needed here.
- Download Zend Framework and place it wherever you’d like. I actually retrieved my copy via SVN so that I can easily upgrade it later. To do this open up terminal and follow these commands:
cd /Applications/MAMP/ mkdir svn cd svn mkdir zendframework cd zendframework svn checkout http://framework.zend.com/svn/framework/standard/trunk
- Now open your php.ini file located under /Applications/MAMP/conf/php5/php.ini
- Search for include_path (around line 411 on mine) and add the location of your zend framework:
include_path = ".:/usr/lib/php:/usr/local/lib/php:/Applications/MAMP/svn/zendframework/trunk/library"
Make sure to include the library directory otherwise you’ll get a blank page in Zend Framework
- Zend Framework also comes with a shell script that will help you with RAD (Rapid Application Deployment), you can create a shortcut to Zend Tools in terminal by adding an alias to your profile under /etc/profile (thanks DS for pointing this out) and make sure to restart terminal after you’ve done so:
alias zf=/Applications/MAMP/svn/zendframework/trunk/bin/zf.sh
- Test if the Zend Tool is installed correctly by showing the version:
zf show version
- Finally navigate to the directory you’d like to create your first project in:
cd /Applications/MAMP/htdocs/
and with Zend Tool creating a project is simple:
zf create project test


This is great info. A lot less complicated than other options I’ve seen people attempting to explain. I did have to tweak it as all of your suggestions didn’t work though. I did made the following variations:
- Download the full framework from http://www.zend.com/community/downloads
- Created /Applications/MAMP/zfw
- Copied the uncompressed framework into /Applications/MAMP/zfw
- Edited php.ini and added the following line to include_path: “/Applications/MAMP/zfw/library”
- Used this to make the alias: alias zf=/Applications/MAMP/zfw/bin/zf.sh
…and that’s it. When I did the SVN version it didn’t include the zf.sh file or the bin folder.
Thanks again, these things are always changing so I thought another newbie like myself might find this useful
Cheers
Thanks for documenting your process. I may have done something differently or already had the Zend Tools enabled from a previous attempt, so I really appreciate the correction and outline of your process.
Have you dove into Zend much yet? I’ve flooded my brain with it in the last week (DB handling, Form generation and Mail so far, attempting to tackle REST tonight)
Nope, just getting up and started with it right now. Hopefully I’m going to fall in love because I deserted Python to come to PHP and all its web-oriented goodness and miss Python dearly. Anyway….
I just noticed that the alias command we both gave won’t stick unless you add it to your profile. So you could add this command into your list of directions maybe:
- In Terminal enter: edit /etc/profile
- Add the line: alias zf=/Applications/MAMP/zfw/bin/zf.sh to the end
- Restart Terminal and switch to the directory you wish to make your project in
- Enter “zf create project [project_name]” or other zf.sh command
Not sure if you had to add the alias to your bash shell but I don’t think it will work if you don’t unless you copy an alias to something in your root path…is that right? Did it just work for you?
Cheers.
Python is a beautiful language and PHP syntax will make you miss it even more, but at least frameworks like Zend make it easier and faster and it really is does dominate the web.
I don’t recall having to add this to my profile, but I did read that elsewhere so it may be worth noting. I’ll do some more research on it with a computer I haven’t tweaked so much.
Good call DS, i added local profile bit into my post and gave credit to ya. Thanks!
An interesting post, I think. Hope that there are more I can read from this site. I will note it in my notebook. thank you.
Glad to have made the process a bit more fluid.
PHP syntax isn’t horrible but Python is just sooo clean and sooo logical. It’s okay, PHP is not as bad as some other options out there.
Cheers
Hi Clay,
Install seemed to go well. Great tutorial.
However, how do I start to use the framework?
I’m not sure how to set up a virtual host on MAMP. Would this be in my httpd.conf file?
How do I do this?
I think once this is set up, I’m all ready to go
Many thanks for any pointers.
Thanks for posting this guide. Along with everyone else, I really appreciated it!
Clay,
I’m having a heck of time trying to setup my Virtual Host on my local machine. Of course I’m using MAMP and I’m in the process of learning Terminal.
Please help….I’m new to programming and I dyeing to get help with setting up the ZendFramework. I hit a wall when I was watching Jon L… http://www.killerphp.com/zend-framework/videos/zend-development-part-1.php
I’m not understanding what the exact steps are when regard to setting my VirtualHost using my Terminal…. Jon stated that he had a special config file called “Panda” … how do I set up a config file for my own?……..
Lost and confused…..but I see the light….
Thank’s for sharing!
Thank you! This was very straight forward and easy to follow
Thanks sooo much this helped me a hell of a lot
Great Tutorial, Thanks
I spend one week, for installing ZF on my Mac. In internet lot of useless info
But this post only working. Thx!
Hello! Thank you for this tutorial! I just have a question.
If I was given a project built on Zend Framework, do I still have to install Zend on my MAMP for local development?
I tested the project and it works fine…but there might be drawbacks I don't know. This is my first encounter with Zend Framework hehe. Would installing Zend Framework for local development necessary if I'm developing from an existing project that used Zend Framework?
Thank you and pardon me for my ignorance at the moment
If it's working already, then ZF is probably included locally in the project (usually linked to as “library” or something similar. If that's the case, you don't need to do anything further to update that project. This post mainly sets up an environment where ZF is included to all projects by default and accessible to multiple projects, thus saving on disk space and setup time.
Hope that helps and good luck with your project!
Yes…in the project there is a library/Zend folder. Thank you for clarifying this to me so I would not blame not installing Zend Framework on my MAMP if something weird happened in the development of the project haha! God Bless ^^
Hey awesome tutorial!!
I have one question for you..Whenever I close the terminal or open a new one and try to type a zf command; I get zf: command not found.
It looks like I have to build the alias each time I want to use zend_tool.
How would I save the following alias command to my system?
alias zf=/Applications/MAMP/svn/zendframework/trunk/bin/zf.sh
Thanks
Hey Nev,
To permanently add an alias to your “memory” just takes a little more terminal input:
vi ~/.bash_profile
hit “a” to enter “edit” mode, arrow down to the bottom and paste in your alias:
alias zf=/Applications/MAMP/svn/zendframework/trunk/bin/zf.sh
then hit the esc key and type “wa” (write all) and “q” (quit)
That will save it in your shell profile of shortcuts (you can do this with many commands) and will be available even if you reboot. To get them to reload right away you can type in:
. ~/.bash_profile
Hope that helps and happy coding
Yes!! that did the trick..hey I grew up in CS next time I am home I'll look you up.
Thanks again,
Nev
Great tutorial. I tried and failed many times on getting zend up and running. Im not knocking ZendCasts but heck this took me maybe all of 10 minutes to set-up versus about 2 hours of watching the ZendCast set up. It was painful to say the least. Quick question: Can I create an alias to mamp via command line? right now this is how I connect to it via terminal::
cd /applications/mamp/Library/bin
./mysql -u root -p -P 3306
Enter password: *****.
There has got to be a better way. I would just like to enter 'mamp' via command line and I am connected. Thanks…
I use this for my alias, and just put in the .bash_profile:
mamp=”/Applications/MAMP/Library/bin/mysql -u root -p -P 3306″
So after that's created you can type mamp, hit enter, and pop in your password.
Works like a charm. Thanks again.
Hi, thanks for the tutorial. I followed all instructions to the letter but just get zf: Command not found when entering zf show version. Not sure what I've done wrong, or how to troubleshoot