On OSX/MacOS do the following in a Terminal window:
Run php --ini
at the prompt by typing it and pressing enter
Reports something like: Configuration File [php.ini] Path: /etc Loaded Configuration File: [none] Scan for additional .ini files in: /Library/Server/Web/Config/php Additional .ini files parsed: [none]
...this is because in /etc there is a file called /etc/php.ini.default as an example and to show it is not in use. You need to copy that file to the name php expects so that you can edit it, like this:
Type:
$ sudo cp /etc/php.ini.default /etc/php.ini [and enter your password]
...then you will see if you run php --ini
again that it now sees your new file:
Typing this: php --ini
at the prompt should report this:
Configuration File [php.ini] Path: /etc
Loaded Configuration File: /etc/php.ini
Scan for additional .ini files in: /Library/Server/Web/Config/php
Additional .ini files parsed: [none]
...now edit /etc/php.ini - you want to make sure the following lines [NOT the same line starting with a semi-colon ';'] are exactly as follows: log_errors = On
[this will turn the logging engine on]
Then, in this section:
; Log errors to specified file. PHP's default behavior is to leave this value
; empty.
; //php.net/error-log
; Example:
;error_log = php_errors.log
; Log errors to syslog [Event Log on Windows].
;error_log = syslog
If you want to log to the
syslog [or Windows Event Log on Windows] then ;error_log = syslog
should become error_log = syslog
However, if as you say, you want to log to a file, you uncomment by removing the leading semi colon to make ;error_log = php_errors.log
become error_log = php_errors.log
or using a full path to place it where you want.
Good luck
Depending on what system you are running, php.ini could have different locations. But where is php.ini hidden? Linux Windows Mac OS X There are few ways to know where is php.ini file. The safest way to know it, is through the following script: Once you run the script in your favourite browser, the function phpinfo[] will output the what you see in the image. You can find much more details with this function, but in order to locate php.ini, we need to focus only on the field “Loaded Configuration File”. In this example [running Mac OSX 10.6], php.ini is located in /private/etc/php.ini Another pretty safe way to locate your php configuration file [assuming you
are running a UNIX system], is with the following BASH command:Find php.ini
Find it with a PHP script
Find it with BASH script
find /-name 'php.ini'2>/dev/null
This command will search for php.ini file in the whole disk, redirecting any error to null. If you suspect your php.ini file is under the directory /etc/, you can substitute “/” for “/etc/”.
The problem with this command, is that you might find multiple php.ini files, and do not really know which one is the active one.
Guess where it is
The location of the file php.ini depends on the installation of PHP. Each distribution goes their way, but there are few common patterns:
Linux | /etc/php.ini /usr/bin/php5/bin/php.ini /etc/php/php.ini /etc/php5/apache2/php.ini |
Mac OSX | /private/etc/php.ini |
Windows [with XAMPP installed] | C:/xampp/php/php.ini |
I hope you have found where php.ini is located!
Instructions on how to change preinstalled Mac OS X PHP to MAMP's PHP Installation and then install Composer Package Management
First, Lets find out what version of PHP we're running [To find out if it's the default version]. To do that, Within the terminal, Fire this command: This should
output the path to the default PHP install which comes preinstalled by Mac OS X, by default it has to be [Assuming you've not changed it before]: Now, We just need to swap this over to the PHP that is installed with MAMP, which is located at Instructions to Change PHP Installation
which php
/usr/bin/php
/Applications/MAMP/bin/php/php5.4.10/bin
[MAMP 2.1.3]
To do this, We need to edit the .bash_profile
and add the MAMP version of PHP to the PATH variable.
Follow these simple steps:
Within the Terminal, run
vim ~/.bash_profile
Type
i
and then paste the following at the top of the file:export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH
Hit
ESC
, Type:wq
, and hitEnter
In Terminal, run
source ~/.bash_profile
In Terminal, type in
which php
again and look for the updated string. If everything was successful, It should output the new path to MAMP PHP install.In case it doesn't output the correct path, try closing the terminal window [exit fully] and open again, it should apply the changes [Restart in short].
Install Composer Package Management
Now you can fire the command to install the composer globally [So you can access it from anywhere]:
$ curl -sS //getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
You can verify your installation worked by typing the following command within the Terminal:
composer
It'll show you the current version and a list of commands you can use if the installation was successful.