Global Rationality
Global Rationality

Reputation: 145

Why doesn't my Mac OS X have a php.ini file? How should I get it so that I can download and install composer?

I appear to have problems with a php.ini file that doesn't exist, or at least not in the right place.

My ultimate goal is to create projects with Laravel on my Macbook Pro (Mac OS X). To install Laravel I have to install Composer (https://getcomposer.org/). To download Composer I am instructed to run the following in Terminal:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" php composer-setup.php php -r "unlink('composer-setup.php');"

Terminal responds:

Some settings on your machine make Composer unable to work properly. Make sure that you fix the issues listed below and run this script again:

The detect_unicode setting must be disabled. Add the following to the end of your php.ini: detect_unicode = Off

A php.ini file does not exist. You will have to create one. If you can not modify the ini file, you can also run php -d option=value to modify ini values on the fly. You can use -d multiple times.

Now, it is my understanding that all Macs have PHP running by default. I seem not to. I really don't understand why, there is no php.ini file where it should be (/etc). I've also made plenty of websites using MAMP, which includes PHP. My guess is that Composer doesn't search for the php.ini used for MAMP, but requires it in etc/. But how do I get a php.ini file in there safe?

I've been stuck at getting Composer and Laravel to work on my Mac for a long time now. Thanks for taking the time to help me. It means a lot.

Upvotes: 3

Views: 3225

Answers (2)

l'L'l
l'L'l

Reputation: 47169

Generally php.ini is located in /etc, you can check where it might be by doing the following command within Terminal:

php -i | grep php.ini

Output:

Configuration File (php.ini) Path => /etc

If you don't have one then I would take the advice of the instructions and create one. There is a "default" one that you can copy to create it:

cp /etc/php.ini.default /etc/php.ini

Upvotes: 2

Rocco Milluzzo
Rocco Milluzzo

Reputation: 1007

I've worked on many projects in laravel on OSX and honestly I suggest you not to set a custom enviroinment, as suggested in documentation, for development you could use:

1) Homestead : based on Vagrant, multiplatform (it needs virtualbox or vmware)

2) Valet : specific for osx (should be faster)

For both you'll get Php, Nginx, mysql, redis, composer, node and so much more completely configured.

I've always used Homested and following the guide you get a complete dev env in minutes

Upvotes: 0

Related Questions