views:

419

answers:

7

I need to enable pdo_mysql in my EasyPhp environment, so I went to php.ini file and uncommented the following line:

extension=php_pdo_mysql.dll

Unfortunately I still have the same problem. I'm using the CLI so I suppose I need to locate the php.ini file used by the CLI. How can I find it?

+3  A: 

You can get a full phpinfo() using :

php -i 

And, in there, there is the php.ini file used :

$ php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini

Well, grepping is probably not going to work on Windows, so, you might have to go through the ouput of php -i by hand, on Windows

Pascal MARTIN
I did that but the weird thing is that it's pointing me the C:\WINDOWS path. And I didn't find it there?
Amokrane
Hu... That's... kind of weird...
Pascal MARTIN
The name of the file is still: php.ini right? Or something starting with php at least?
Amokrane
Then this php instance used no php.ini at all but the default values. The `Configuration File` line of phpinfo() shows the last place where php looked for an ini file. That can either be the place where it found such a file or the last option which happens to be %SYSTEMROOT% on windows.
VolkerK
@pascal: `php -i | find "Configuration file"` should work on Windows. Definitely not as powerful as grep, but `find` will do basic string searching for you. Of course, if php -i dumps its output to stderr, you're probably SOL.
Marc B
+1  A: 

From what I remember when I used to use EasyPHP, the php.ini file is either in C:\Windows\ or C:\Windows\System32

Tim Cooper
Right it's telling me C:\WINDOWS. But I didn't find it there seriously!
Amokrane
+2  A: 

You can use get_cfg_var('cfg_file_path') for that:

To check whether the system is using a configuration file, try retrieving the value of the cfg_file_path configuration setting. If this is available, a configuration file is being used.
Unlike phpinfo() it will tell if it didn't find/use a php.ini at all.

var_dump( get_cfg_var('cfg_file_path') );

And you can simply set the location of the php.ini. You're using the command line version, so using the -c parameter you can specifiy the location, e.g.

php -c /home/me/php.ini -f /home/me/test.php
VolkerK
+1  A: 

create a phpinfo file and put the function phpinfo(); in it

Brandon_R
+2  A: 

If you want all the configuration files loaded, this is will tell you:

php -i | grep "\.ini"

Some systems load things from more than one ini file. On my ubuntu system, it looks like this:

$  php -i | grep "\.ini"
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
Scan this dir for additional .ini files => /etc/php5/cli/conf.d
additional .ini files parsed => /etc/php5/cli/conf.d/apc.ini,
/etc/php5/cli/conf.d/curl.ini,
/etc/php5/cli/conf.d/gd.ini,
/etc/php5/cli/conf.d/mcrypt.ini,
/etc/php5/cli/conf.d/memcache.ini,
/etc/php5/cli/conf.d/mysql.ini,
/etc/php5/cli/conf.d/mysqli.ini,
/etc/php5/cli/conf.d/pdo.ini,
/etc/php5/cli/conf.d/pdo_mysql.ini
AlReece45
A: 

Just run php --ini

Mchl
A: 

In your php.ini file set your extension directory, e.g:

extension_dir = "C:/php/ext/"

You will see in you PHP folder there is an ext folder with all the dll's and extensions.

Marc Uberstein