How to set php.ini standard path for PHP CLI on Windows?

Brief introduction to the problem:

I need to download pdo_mysql to run the command php app/console doctrine:database:createand other commands for Symfony2.

I found a way to do this by running php -c "path/to/my/php.ini" app/console doctrine:database:create

Problem:

Since I do not want to add the path to my php.ini every time I run commands in the PHP CLI, where / how can I configure Windows, so that every time I print php somecommand in the console it will load my desired php.ini file?

+2
source share
3 answers

What if you add path/to/your/php.inipaths to the environment variable and then just runphp -c "php.ini" app/console doctrine:database:create

Could you try it?

+1
source

.CMD, PHP :

path/to/php.exe -c "path/to/php.ini" %1 %2 %3 % %5 %6 %7 %8 %9

- phpcli.cmd. , . , , phpcli, php.

+2

, php.ini, PHPRC. , , "".

PHP: http://php.net/manual/en/configuration.file.php

Windows - " "; " " "" "" , "" , " " "" , "PHPRC" .ini ... , C:\MAMP\conf\php5.6.28.

( Win 7, , )

You can check its operation by executing php --inifrom the command line, the output should look something like this: Configuration File (php.ini) Path: C:\Windows Loaded Configuration File: C:\MAMP\conf\php5.6.28\php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) you can also do it echo %PHPRC%from the Windows command line or echo $PHPRCfrom Cygwin / bash / MinGW, etc. You will have to restart all existing terminal sessions for this to take effect, but in my experience this works for all three, since bash environments also inherit Windows environment variables.

+1
source

All Articles