Can't set/find detect_unicode to Off

2019-04-01 02:58发布

问题:

I'm want to start using phpDocumentor and the manual installation keeps throwing an error about me not having set detect_unicode = Off in my php.ini in Terminal.

When I add it to my php.ini it doesn't take and I get the same issue when running the install. Nobody seems to have this problem, and for the life of me I can't figure it out.

https://github.com/phpDocumentor/phpDocumentor2/blob/develop/README.md#installation

What am I missing? (I did restart the MAMP server after the php.ini edit)

Screenshot of the error in terminal...

回答1:

If you have MAMP/MAMP Pro installed then the problem is that the PHP version available to your terminal will most probably be the system version located in:

/private/etc/

I had the same problem but in my case I didn't have a php.ini file in that directory so the best way to resolve it is to just create a symbolic link to the PHP version currently in use in your MAMP/MAMP Pro installation:

php.ini -> /Applications/MAMP/bin/php/php5.3.14/conf/php.ini

That solves the issue. Just change the php version php5.3.14 to whatever version of PHP you've selected to use in MAMP.

As @moderndegree mentions above, you can then optionally make this available to the terminal in the future by editing your path variable in your bash/zsh/etc:

export PATH="/Applications/MAMP/bin/php/php5.3.14/bin:$PATH"


回答2:

You must not be editing the right php.ini if it still is enabled. Run php -i | grep ini to find all the ini files that are loaded.

The relevant lines are those two:

Loaded Configuration File => ...
Additional .ini files parsed => ...


回答3:

The problem is that you are probably hitting a different php install.

Try the following:

which php

If you get anything other than, /Applications/MAMP/bin/..., you need update your environment to point to MAMP's installation.

To do this, you will need to add the following to .bash_profile (please update the path to match your setup):

export PATH="/Applications/MAMP/bin/php/php5.3.6/bin:$PATH"

Reload .bash_profile with the following command:

source .bash_profile

After you do this, you should be pointing to the correct php installation. Try which php again to confirm. Now run php -i | grep ini to confirm that the correct php.ini file is being loaded. As Seldaek stated, the relevant lines are:

Loaded Configuration File => ...
Additional .ini files parsed => ...


回答4:

As I remember, MAMP uses configuration templates. So you should edit php.ini template. The actual php.ini will be regenerated from the template everytime you restart MAMP.



回答5:

I faced the same problem for composer-php and i add this line manually into php.ini file. Like this:

sudo /private/etc/php.ini

then add this line "detect_unicode = Off"

detect_unicode = Off

then its work and i installed composer. You can see this How to disable "detect_unicode" setting from php.ini? (trying to install Composer)



回答6:

If you can't change your /usr/local/bin/php/php.ini file, remember to keep using '-d detect_unicode=Off' for all your php calls like so:

curl -s https://getcomposer.org/installer | php -d detect_unicode=Off

php -d detect_unicode=Off composer.phar install 

If you are able to change your php.ini file, then add the following to the end of your php.ini:

detect_unicode = Off