Home > Computers, Guides, Programming > Symfony + Mac OS X + pdo_mysql.so

Symfony + Mac OS X + pdo_mysql.so

April 27th, 2009
UPDATE!
May 10th, 2009 – This tutorial is not complete. Following these instructions will only get command line version of PDO_MYSQL working. I have written a new guide that avoids the built-in versions of PHP and Apache. Read the updated tutorial »

I recently started working my way into the world of the PHP framework Symfony. While following the superb Jobeet tutorial, I encountered an error involving PDO_MYSQL and Mac OS X. I spent an hour trying to trace down the problem and another hour finding a solution. And as always, when something takes me too long to solve, I write a guide for it!

The setup

I tried to run this command while following the Jobeet tutorial:

php symfony propel:insert-sql

The error

>> schema    converting "/Users/eyeRmonkey/w...obeet/config/schema.yml" to XML
>> schema    putting /Users/eyeRmonkey/works...eet/config/generated-schema.xml
>> propel    Running "insert-sql" phing task
Execution of target "insert-sql" failed for the following reason: /Users/eyeRmonkey/workspace/jobeet/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:275:1:  [wrapped: could not find driver]
   [phing] /Users/eyeRmonkey/workspace/jobeet/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/build-propel.xml:275:1:  [wrapped: could not find driver]

 Some problems occurred when executing the task:
   build-propel.xml:275:1:  [wrapped: could not find driver]
   If the exception message is not clear enough, read the output of the task for more information  

The root problem

The distribution of PHP that comes with OS X doesn’t have the pdo_mysql.so library loaded. You can determine this by looking at output from php -m.

The solution

After much searching, I finally discovered the proper way to compile the pdo_mysql.so library. This all assumes that you have PHP and MySQL installed the same way I do. (source)

Compiling PDO_MYSQL:

  1. Download PDO_MYSQL
  2. Run the following commands (replacing x.x.x with the version of PDO_MYSQL that you downloaded)
cd ~/Downloads/PDO_MYSQL-x.x.x/PDO_MYSQL-x.x.x
phpize
./configure '--with-pdo-mysql=shared,/usr/local/mysql'
make
sudo make install

Updating your PHP configuration:
Now add the following two lines to the file /etc/php.ini under the “Dynamic Extensions” section:

extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20060613"
extension=pdo_mysql.so

Save the file and you’re done.

The conclusion

Many people had this problem. It shouldn’t take hours of detailed searching to find a solution. Back to Symfony!

Computers, Guides, Programming , , , , , ,

  1. cathleen
    April 29th, 2009 at 10:31 | #1

    Thank you! Thank you! Thank you!

    It took me *hours* of searching and finally found this page and I followed your instruction to install pdo_mysql.so and I was able to bypass the problem:

    “Some problems occurred when executing the task:

    build-propel.xml:275:1:  [wrapped: could not find driver]"
    
  2. Arnold
    May 14th, 2009 at 15:50 | #2

    Thanks for the article. I followed the instruction and can get pass the command line portion of the tutorial. But now when I hit the browser, it said “Unable to open PDO connection [wrapped: could not find driver]. Guess that’s what you mean in the updated section. Any quick fix for that?

  3. Auzigog
    May 14th, 2009 at 16:04 | #3

    As far as I can tell, the problem is not something you can fix. That’s why I ditched the built in version of Apache/PHP and went with MAMP instead.

  4. May 23rd, 2009 at 17:53 | #4

    Woot! Thanks for the tip. This finally got Symfony working for me with MySQL.

  5. June 18th, 2009 at 05:50 | #5

    big thanks, very simple and easy decision for this problem, i had afraid that i need to recompile PHP…

  6. Lashae
    August 5th, 2009 at 05:41 | #6

    You really saved my life! However:

    [05-Aug-2009 16:38:54] PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php/extensions/no-debug-non-zts-20060613/pdo_mysql.so’ – (null) in Unknown on line 0

    What does this mean?

  7. shardul chokshi
    October 28th, 2009 at 13:25 | #7

    I installed PDO_Mysql following your instructions in mac .
    It did well and also mofified php.ini file
    but on restarting server it’s not showing up

  8. July 17th, 2010 at 02:49 | #8

    Thanks. Just to help the search engine:

    This fixes “couldn’t locate driver named mysql” issue on symfony.

  9. SuperRadis
    February 27th, 2012 at 09:54 | #9

    Thank you ! Saved me. :)

  1. No trackbacks yet.