Reputation: 1564
I am working on a symfony project using MAMP.
I am trying to load data into sql from Terminal with this script:
php symfony doctrine:insert-sql
I am getting this error:
Couldn't locate driver named mysql
The forums have explained you should have pdo_sql
enabled.
This is enabled in MAMP/conf/php5.2/php.ini
and MAMP/conf/php5.3/php.ini
The researched documentation states that the php.ini
file in the CLI is different from the php.ini
file located in apache.
How can I locate and edit the php.ini
file in the CLI, which is obviously different from the ones located in the MAMP directory?
Upvotes: 2
Views: 10846
Reputation: 1564
OK, I have made multiple changes to multiple files. I'm not sure where it started working, but it is good to go now. I am going to go through my edits and hopefully it will help others with this issue.
First, I made files visible in the Finder using this script in the Terminal:
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
Second, I located where my CLI php.ini file was located using Terminal(Thanks to Cassy) using the script he provided:
php -info | grep Confi
This outputs similar to:
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /private/etc/php.ini
This location is not correct to activate the pdo_mysql.so file needed for symfony using MAMP.
So, in hammer to housefly fashion, I covered these steps:
Open php.ini in /Applications/MAMP/conf/php5.3/ and copy the following line:
extension=pdo_mysql.so
Open the php.ini in /private/etc/ (This is where you have to have hidden files set to visible), and paste the above code (extension=pdo_mysql.so) into the file. I pasted it under the commented out extensions, but I do not think it matters.
Open .bash_profile in the Users directory (This is normally your computer name, ie Carey, Steve, Holly)
Insert the following code:
export PATH=:/Applications/MAMP/bin/php5.3/bin
Lastly, open httpd.conf and paste the following code:
php_value include_path "/Applications/MAMP/conf/php5.3/php.ini" PHPIniDir "/Applications/MAMP/conf/php5.3/php.ini"
After restarting Apache, I looked at my php info in Terminal:
php -i
And it said this:
Configuration File (php.ini) Path => /Applications/MAMP/conf/php5.3
Loaded Configuration File => /Applications/MAMP/conf/php5.3/php.ini
Now in Terminal, type php -m and it will give you a list of php modules. Look for pdo_mysql in the list.
If it is there, using symfony to build and populate your database should work.
Upvotes: 3
Reputation: 10248
run this on the command line:
php -info | grep Confi
it should give you an output like
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => (none)
But you don't have to edit it. You can just simply use the one that is used by MAMP:
php -c /path/to/your/php.ini symfony doctrine:insert-sql
Upvotes: 3