A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Note to Self: PHP shipped on Mac OSX is broken and old

I had to learn the hard way. On my Mac I have MAMP installed. MAMP great piece of software that installs Apache, MySQL and PHP. It makes everything easy. As of this post, the PHP included in MAMP is PHP Version 5.2.6. That is pretty acceptable – it should work with Zend Framework.

I wanted to use Zend Framework for a small project. So I downloaded the latest copy of Zend Framework and extracted it inside my htdocs directory. I used Zend_Tool to create a project, so I did everything by the book to make it work — But it didn’t. I have been trying since yesterday. And today, I found out that MacOS ships with an old copy of PHP.

I overlooked the PHP Version when I ran this

php -i | more

in the terminal. The PHP CLI was using PHP Version 4.4.9. Big FAIL.

The whole time I was doing “zf.sh” on the console, it was using the PHP that was shipped with the OS (PHP Version => 4.4.9).

BUT I did not know that MacOSX is shipped with PHP — the PHP shipped with the OS is broken and old — PHP Version => 4.4.9.

This entry was posted in General and tagged , , , , . Bookmark the permalink.

8 Responses to Note to Self: PHP shipped on Mac OSX is broken and old

  1. James says:

    I put the ‘Zend’ folder inside:

    /Applications/MAMP/bin/php5/lib/php/

    so it’s on php’s include path.

    and the ‘zf.php’ and ‘zf.sh’ inside:

    /Applications/MAMP/bin/php5/bin/

    and then with MAMP running you can create access the zf.sh file via:

    /Applications/MAMP/bin/php5/bin/zf.sh

  2. James says:

    I meant you can access the zf.sh file from terminal using:

    /Applications/MAMP/bin/php5/bin/zf.sh

    too early in the morning for me

  3. I’ve got the same problem, I solve it renaming the osx’s executable into “php.orginal” and editing the /etc/profile file with the following lines (I use xampp instead of mamp):
    export PATH=$PATH:/Applications/XAMPP/xamppfiles/bin
    alias php=”/Applications/XAMPP/xamppfiles/bin/php”

  4. Wenbert says:

    My problem was that PHP CLI is not the same as the one running on MAMP. So right now, I have 2 PHPs. One in MAMP and the other one in /opt/local/bin/php. I used Macports http://www.macports.org/ . Macports is a lifesaver. It is so easy to install. After installing it, I just ran:

    sudo port install php5

    And wait for about an hour (probably more).

    After the installing PHP5, I searched for the php.ini file. I found it in:

    /opt/local/etc/php5/php.ini

    Opened it and editted the include_path to this:

    include_path = ".:/php/includes:/Applications/MAMP/bin/php5/lib/php"

    NOTE: the Zend folder is found in /Applications/MAMP/bin/php5/lib/php

  5. I can’t understand why install two php’s executables.
    Mamp is shipped with a php cli that is placed into /Applications/MAMP/bin/php5/bin/ if you use this you don’t have to set another php.ini but use the same that you have set for MAMP.
    If you use the solution that i’ve previously write when you use the command php in the terminal you call the MAMP’s php cli.

  6. Wenbert says:

    @Luca Bernardi you are right it. I could have just created a symbolic link to replace the existing PHP shipped with the OS.

    Right now, I am confused whether I should continue to use MAMP or use Macports to install Apache2+MySQL…

  7. personally I prefer spend my time coding so I love MAMP’s /XAMPP’s “on-click” solution :D

  8. It took some digging, but i came across this blog through some Google searching. The comments posted here is what helped me finally figure out how to put it all together.

    So to recap the few here that originally put this solution together.

    Zend Framework/Zend Tool with MAMP

    Step 1:
    Copy the Zend Framework Library into
    /Applications/MAMP/bin/php5/lib/php/
    this way you will not have to edit the php.ini file, if you wish to have the library elsewhere you will have to put its path in the include_path variable in your php.ini file in MAMP

    Step 2:
    Copy the ‘zf.php’ and ‘zf.sh’ into:
    /Applications/MAMP/bin/php5/bin/

    Step 3:
    Find your Mac’s php build by typing
    which php
    Rename it to php.original like example
    sudo mv php php.original

    Step 4:
    Edit your .profile in your Home Directory add lines below
    export PATH=$PATH:/Applications/MAMP/bin/php5/bin
    alias php="/Applications/MAMP/bin/php5/bin/php"

    If you have done these four steps you will see your version number upon entering the command
    zf.sh show version
    from any directory.
    You are now setup to go

Leave a Reply to James Cancel 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>