Search code examples
phpsymfonydoctrinemysql-connector

How can I get a database running on Symfony


OBJECTIVE:

I am trying to simply create a database using doctrine in Symfony. I have my project installed in xampp>htdocs

I HAVE TRIED:

I have the apache server running and can view my site locally no problem.
When I follow the instructions in the documentation, I am able to successfully run these two commands:

composer require symfony/orm-pack
composer require --dev symfony/maker-bundle  

I then go to my .env file and change this line:

DATABASE_URL="mysql://db_user:[email protected]:3306/db_name?serverVersion=5.7"

to be this line:

DATABASE_URL=mysql://root:[email protected]:3306/symphart

-I have configured the root user to use the password "pass" and haved logged in to phpmyadmin -successfully.

-php.ini-production and php.ini-development both have pdo_mysql enabled

THE PROBLEM:

When I run the command:

php bin/console doctrine:database:create

I get the error:

C:\xampp\htdocs\symphart>php bin/console doctrine:database:create
[error] Error thrown while running command "doctrine:database:create". Message: "An exception occurred in driver: could not find driver"


In AbstractMySQLDriver.php line 128:

  An exception occurred in driver: could not find driver


In Exception.php line 18:

  could not find driver


In PDOConnection.php line 37:

  could not find driver

Here is a screenshot of the error message: error message screenshot


Solution

  • SOLUTION:

    Windows 10 has two files in the Xampp folder with the ".ini" extension, and neither are what you need. Uncommenting stuff in them did nothing for me. It wouldn't add modules.

    On windows 10 you need to look in "C:\Xampp\php" for a file called "configuration". It's exactly like an ini file but has no extension. Editing THAT file will enable modules.

    Thanks for all the effort everyone put into answering my question. You were all essentially right. Just missing the naming convention for Windows 10 it seems.