My name is Clayton McIlrath and I am an entrepreneur currently living in CO. I personally enjoy the process of learning, exploring, and doing all things creative as well as sharing my experiences with others. Being an entrepreneur and business owner, I hope that my experiences may help someone else start their own venture and find success and freedom as I have! Feel free to contact me anytime for questions or opportunities.

close
more

»

«


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.

  1. Get MAMP up and running, no special setup is needed here.
  2. 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
    
  3. Now open your php.ini file located under /Applications/MAMP/conf/php5/php.ini
  4. 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

  5. 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
  6. Test if the Zend Tool is installed correctly by showing the version:
    zf show version
  7. 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

  • ds

    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

  • http://thinkclay.com Clay McIlrath

    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)

  • ds

    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.

  • http://thinkclay.com Clay McIlrath

    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.

  • http://thinkclay.com Clay McIlrath

    Good call DS, i added local profile bit into my post and gave credit to ya. Thanks!

  • http://diendankienthuc.net Viet Su

    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.

  • ds

    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

  • Michael

    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.

  • Patrick

    Thanks for posting this guide. Along with everyone else, I really appreciated it!

  • Scott

    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….

  • http://emeich.com cactork

    Thank’s for sharing!

  • http://maxbeatty.com Max

    Thank you! This was very straight forward and easy to follow

  • http://www.designinfusion.co.uk Dean

    Thanks sooo much this helped me a hell of a lot :P

  • Dnakhla

    Great Tutorial, Thanks

  • http://twitter.com/unglued Aleksandr Matrosov

    I spend one week, for installing ZF on my Mac. In internet lot of useless info :( But this post only working. Thx!

  • Justn Cribb

    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 :D

  • thinkclay

    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!

  • Justn Cribb

    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 ^^

  • Nev Harrison

    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

  • thinkclay

    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 :)

  • Neveo

    Yes!! that did the trick..hey I grew up in CS next time I am home I'll look you up.

    Thanks again,
    Nev

  • http://www.facebook.com/profile.php?id=509427346 Demetrius Ford

    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…

  • thinkclay

    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.

  • http://www.facebook.com/profile.php?id=509427346 Demetrius Ford

    Works like a charm. Thanks again.

  • simonchilton

    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

  • Mark

    hey dude!

    for some reason, its not finding my include_path!!

    i have
    include_path = “.:/Applications/MAMP/htdocs/helloworld/library/Zend:/Applications/MAMP/bin/php5.3/lib/php”

    the original include_path was
    include_path = “.:/Applications/MAMP/bin/php5.3/lib/php”

    first off its strange how my original path differs from you path?!
    its like your pointing to macs own php install and not the MAMP version

    so when i type zf show version now it says:

    ***************************** ZF ERROR ********************************
    In order to run the zf command, you need to ensure that Zend Framework
    is inside your include_path. There are a variety of ways that you can
    ensure that this zf command line tool knows where the Zend Framework
    library is on your system, but not all of them can be described here.

  • shadowsK

    the path i am using is /Applications/MAMP/htdocs/helloworld/library/ and it is working for me.

    hope it works for you

  • Peteguestlist

    Just wanted to reach out and say thank you for taking the time to pull together such a comprehensive tutorial on installing and setting up zend.

  • http://web-ethical.co.uk Chris

    Hi, Thanks for this it works except I would say that for those using MAMP-Pro you need to alter the template for your php.ini from the File > Edit Template menu otherwise it kindly overwrites your changes.

  • http://thinkclay.com Clay McIlrath

    Sorry for the late reply, but if other users should come across this issue.. the alias was created on the fly but will be valid in a single terminal session. If you need zf alias permanently you can edit your ~/.bashrc file and add that line of code in there and then reload your profile with “. ~/.bashrc”

  • Ryan A

    dang, that was easy!

  • Phil

    Would love to have a tutorial on SVN. If you get some free time, please offer your thoughts.

  • http://twitter.com/opentuned Stefan Cross

    Excellent stuff, just 2 points that might help people;

    1) You might find that you need to specify the htdocs folder in the path
    ie /Applications/MAMP/htdocs/svn/zendframework/trunk/bin/zf.sh

    2) Dont forget when you edit the ini file you will need to restart MAMP! Also I believe in order to run the new aliases you might have created, you will need to open a new shell for them to take effect…

    Good work folks!

  • Teste

    ThxSFM!
    d ^_^ b

  • chhivhorng ly

    here is my website that i would like to put many technologies on it, someone have any idea for me.

    please here http://www.khmerlearn.com 

  • Gustav

    I’ve been working with PHP for six years so I guess I’m an idiot but I couldn’t figure out how to do this even with the help of the Zend manual and two Zend beginner’s guide books. Was about to give up when I found this tutorial so many many thanks.

  • http://twitter.com/planetfrank planetfrank

    Thx Cly. I cant believe it was SO easy!

  • http://www.webdeveloperblog.co.uk Jay Murphy

    Thank you for this amazing article! It was so straight forward and made installing zend on MAMP easy. Thank you again :)

  • http://twitter.com/planetfrank planetfrank

    what a great post, i finally understand how ZF command line tool !!! or at least how to make it work

  • Neotoxic

    Thank you for this tutorial, it was clear and easy to follow.

  • Capoo Polacco

    Thank you Chris!

  • Capoo Polacco

    Thank you a lot !!!!

  • Capoo Polacco

    Thanks Stefan.

  • Travis Kaufman

    Just a quick tip for anyone running into the same problem as I was:

    If you’re using MAMP Pro and running it under the user www/mysql and have your path to zf in your user directory (i.e. /Users/your_name/*), you won’t be able to access it due to _www not having permissions to access that directory. I was experiencing this issue but didn’t realize this until I had banged my head against the wall enough times to notice. So I moved my zf folder into /Applications/MAMP, updated my php.ini files in both [MAMP_ROOT]/conf/php-5.2/ and using “Edit Template” and now it’s finally working. 

  • Ola

    Perfect!

close