Nothing like coming back from a hiatus with a WTF? post.
My favorite “cake bake” started failing with the message in the subject; as well it seems that I am not the only one who had suffered from the problem… (just give it a quick check on google).
After a little research here’s a summary of issues and steps to check:
The problem is caused the the fact that the PDO drivers are not available when you run php5 in cli mode (i.e. “cake bake”).
- First thing you’d want to check is which php.ini file is being used by your php (in cli mode!).
- In your terminal (or command prompt), run: php –ini. This will show the location of the currently used files. In many cases it is possible that your system php is not the same as your web server php, which you might have installed with something like XAMPP. If this is the case you need to change your path to use the correct install of php, which should have the necessary drivers available.
- Next step would be to check your php.ini (which is sometimes broken into a few config files). Check the PDO settings to make sure you have the correct extension enabled (might be as simple as un-commenting a line). For example, I am using MySQL therefore I needed to have MySQL PDO extension available (when running in cli!). It was working perfectly well “on the web”.
- Turns out I needed to run: sudo apt-get install php5-mysql
That was unexpected a little since CakePHP had no connection problems to MySQL, but there you go. This should cover all possible cases.
If you find other solutions not outlined here, please share.