Symfony 2 PDOException Could Not Find Driver – with MAMP 2.0

 
Symfony 2
 
In case you got the mentioned PDOException you probably didn’t use the correct PHP (most likely you used the system’s PHP instead of MAMP’s).
 
I ran into the exception while trying to create a scheme with doctrine on my Macbook Pro running Snow Leopard:
> php app/console doctrine:schema:create
 
Symfony 2

Solution:

The Solution is quite easy. We are going to create a permanent alias for the MAMP PHP by making an entry to the ~/.bash_profile.
 
Run the following command:
> sudo nano ~/.bash_profile
 
Now add this line (you can change the alias though) and save with [Ctrl]+[O]:
alias php2='/Applications/MAMP/bin/php5.3/bin/php'
 
After a terminal-restart you should be able to use MAMP’s PHP by typing php2.

2 Comments (+add yours?)

  1. Alexander
    Feb 04, 2012 @ 01:36:10

    I had the same problem with my MAMP 2.0.5 and Mac 10.6.8
    Everything was installed correctly, the issue was that in CLI php is calling different php file.
    You should edit .profile file.
    open .profile and change:
    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    replace with:
    export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php/php5.3.6/bin/:$PATH

    With my machine the issue was that I had installed MacPorts and that programme was added that PATH in my .profile file.

    That took me 1 day to find out what was the issue.

    Reply

  2. Aleksandar Palic
    Feb 04, 2012 @ 15:15:27

    Thanks for your reply – I’m going to check your suggestion as fast as I can!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Blog Stats

  • 4,457 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 2 other followers

Follow

Get every new post delivered to your Inbox.