PHP on OSX

I’m wanting to update the local version of PHP on my Mac… i’ve been doing some digging and got a little confused.

If i run php -i from the terminal it says:


        $ php -i
        phpinfo()
        PHP Version => 5.3.15
        Configuration File (php.ini) Path => /etc
        Loaded Configuration File => (none)

I was sure i had 5.4 installed so ran phpinfo();


        PHP Version 5.4.5
        Loaded config file: /usr/local/php5/lib/php.ini

A problem i’m having is i can’t seem to make any php.ini file work, i’m getting lots of

        Notice: Undefined index:

errors, so error reporting is too high, but no matter how many php.ini files i find and edit it’s not taking effect…

I have no idea which version of PHP is being used or why there is two.

Is it possible to disable or remove one of them so i know exactly whats going on, and then i can update it to a newer version?

Thanks

okay, you have two versions installed (this is true for linux too).

First you need to establish where php5 is located and where it’s configuration files are at (try running whereis php5) – mine is located at /etc/php5.
Next you need to edit the php.ini that is inside the configuration folder (there may be an apache2, cli, and conf.d folder inside the php5 configuration folder).

Open the appropriate php.ini and find the following:

error_reporting =

Personally, I like my dev machine reporting too much, as that will only help you write better code. However, if that is not what you want, change it to E_ALL & ~E_NOTICE

hmm thats strange i managed to find it in /usr/local/php/lib/php.ini - modified and it worked, strange thing is i modified it yesterday and it didn’t work?

is it easy enough to upgrade this 5.4 installation to 5.5?

It doesn’t surprise me that the location of your ini file was different, mine was based on Linux setups, so I was sure yours would still be different, just didn’t know how much different (another thing to keep in mind is if you want Apache to see the difference you have to restart apache).

As for 5.5, that is still very much in beta and likely doesn’t have binaries for all operating systems yet, so unless you are comfortable with building from source or you desperately need a feature from 5.5, I’d recommend using 5.4 for now.