Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
This tutorial has a new version, check it out!

Database Config and Automatic Table Creation

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

We described the genus table to Doctrine via annotations, but this table doesn't exist yet. No worries - Doctrine can create it for us!

And actually, we don't even have a database yet. Doctrine can also handle this. Head to the terminal use the console to run:

./bin/console doctrine:database:create

But wait! Can Doctrine do this yet? We haven't told it anything about the database: not the name we want, the user or the password.

Configuring the Database

Where do we do that? The same place that everything, meaning all services are configured: app/config/config.yml. Scroll down to the doctrine key:

... lines 1 - 43
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
... lines 60 - 72

Ah, this is what tells Doctrine all about your database connection.

But, the information is not hardcoded here - these are references to parameters that are defined in parameters.yml:

... lines 1 - 3
parameters:
database_host: 127.0.0.1
database_port: ~
database_name: symfony
database_user: root
database_password: ~
# You should uncomment this if you want use pdo_sqlite
# database_path: "%kernel.root_dir%/data.db3"
... lines 12 - 15

Update the database_name to aqua_note and on my super-secure local machine, the database user is root with no password.

Go Deeper!

Find out more about these parameters in our Symfony Fundamentals Series.

Back to the terminal! Now hit enter on the command:

./bin/console doctrine:database:create

Database created. To create the table, run:

./bin/console doctrine:schema:update --dump-sql

This looks great - CREATE TABLE genus with the two columns. But this didn't execute the query yet - the --dump-sql option is used to preview the query if you're curious. Replace it with --force.

./bin/console doctrine:schema:update --force

So hey guys, this is really cool - we can be totally lazy and let Doctrine do all the heavy database-lifting for us. This doctrine:schema:update command is actually more powerful than it looks - it's going to "wow" us in a few minutes.

But first, let's learn how to insert data into the new table.

Leave a comment!

77
Login or Register to join the conversation
Default user avatar
Default user avatar 3amprogrammer | posted 4 years ago

I find it very usefull to use https://github.com/bamarni/.... This way you dont have to look at some reference all the time when dealing with ./bin/console :)

1 Reply

Hi 3amprogrammer
is work also for a Windows operating system?

I miss this step:
Add the following line at the end of your shell configuration file (~/.bash_profile or ~/.zshrc) :

1 Reply

Hey Teo!

Yes and no. That library definitely won't be able to give you auto-completion for Windows cmd prompt. BUT, if you use Cygwin, I believe it's supported - here is some information about the bash_profile file with Cywgin: http://cs.nyu.edu/~yap/prog...

I hope this helps you get it working!

Reply

Great tip - I use it too and love it!

Reply
Sara Avatar

If you did not have MySql already installed on Mac I found 2 good resources.
https://youtu.be/q9S51sykd1A
and
https://stackoverflow.com/q...

1 Reply

Hey Sara,

Thanks for sharing it with others. I'd personally prefer to install MySQL with Homebrew as well as PHP, web servers, and other console things :)

Cheers!

Reply
Default user avatar
Default user avatar Lee RavenGod Ingram | Sara | posted 4 years ago

Yep this was me. I brewed up some MySQL and the Doctrine create command worked perfectly.

Reply
Default user avatar

Hi.

I've been struggling with this part for a few days now and I've reached a point where i simply cant figure it out on my own.
I changed the settings for my local connection in parameter.yml, but i kept getting an error saying access denied to root@localhost password: no. No matter what I put in parameter.yml this was my response.
I changed my root password to null and boom. It worked. i could run doctrine:database:create however... It creates a DB called 'symfony' even though I changed the db_name first in parameter.yml and then hardcoded in config.yml.

When i then try to run doctrine:schema:update --dump-sql it results in an error saying "No Metadata Classes to process."

My EntityClass looks like this:


namespace AppBundle\Entity;


use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="blog_posts")
*/
class Post
{
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
private $id;

/**
* @ORM\Column(type="string", length=100)
*/
private $title;

/**
* @ORM\Column(type="text")
*/
private $description;

/**
* @ORM\Column(type="text")
*/
private $content;

/**
* @ORM\Column(type="date")
*/
private $date;

}

And I've trying to change the config.yml to contain this under orm:


orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
AppBundle:
type: annotation
is_bundle: false
dir: %kernel.root_dir%/../src/AppBundle/Entity/
prefix: AppBundle\Entity
alias: AppBundle

The directory structure is as shown throughout these great tutorials :)
I hope you can help me resolve this, or clearify the error for me. Which seems to me like the changes made in/for config.yml ain't being saved for some reason.?

1 Reply
Default user avatar
Default user avatar Michael Stratford | Kaiser | posted 4 years ago

FWIW I had the same issue with the metadata error message, and my problem was the namespace incorrectly ended up as src\AppBundle\Entity. Removing the src\ prefix corrected the issue. Likely not the problem you were having, but for the sake of contributing in case anyone else bumps their head against this, I figured it was worth sharing.

Reply

Hey Michael,

I think it's worth! Thanks for sharing it ;)

Cheers!

Reply

Hey Kaiser!

Ok, let's get you fixed up :). My guess is that you had one error, and may have caused other little errors while debugging the first. If we straighten everything out, we should be good! So let's look at each thing, one-by-one.

First, about the database password. Obviously, it turns out that you don't have a password, which is why null worked. But, I agree that it's a little weird that when you *did* add a password, it still said password NO, instead of password YES. But honestly, I would just ignore that if it's working, because I'm guessing there was some small misconfiguration causing this confusion. I just tried locally - if I set my password to something, I get an access denied password YES.

Second, about the database name. This seems similar to the database password! It seems that we're having some configuration confusion somewhere, but I'm not sure where. As you already know (based on your comment), when you set database_name in parameters.yml, this only works because that parameter is referenced in config.yml, under the doctrine.dbal.dbname key. So, if you are setting that key directly - which I know you tried - then there's other magic happening: this *should* set the database name. The fact that you're having this problem and the password problem makes me wonder if there isn't - somehow - some other database configuration somewhere else. Look in all of the files in app/config for a "doctrine" root key. In short: your configuration is not behaving as it should. And although you should not need to ever do this, you should try clearing your cache (bin/console cache:clear) just in case. Also, are you using a VM? I'm trying to think if it's possible that you're editing the files, but they're not actually updating on your VM (or something). It just doesn't make sense!

Finally, about the "No Metadata Classes to Process". Assuming you have normal, default doctrine configuration (which, we're not sure is true at this point!) then this only happens if your entity class has a bug in it. Things to check:

A) That your class matches your filename (so, Post.php)
B) That the file lives in the Entity directory and the namespace is correct (your namespace IS correct)
C) That there is an <?php tag on top (this happens more often than you would think!)
D) That your annotations have /** (with two stars) - you're good here too!

But also, remove the "mappings" config key you added. I'm guessing you did this while trying to debug, but it's not necessary: the auto_mapping: true above tells Doctrine to look in the Entity/ directory of all of your bundles :).

Phew! Ok, let me know what you find out!

Reply
Oda Avatar

Hi!
I not have the command:
$ bin/console doctrine:schema:update
Command "doctrine:schema:update" is not defined.

This is very strange because I have the same code in two servers (git cloned) and in one I have the command "doctrine:schema:update" in the second server I do not have it!

In the second server the command print the following message: "Command "doctrine:schema:update" is not defined."

The command $ bin/console prints :

[...]
doctrine
doctrine:cache:clear-collection-region Clear a second-level cache collection region
doctrine:cache:clear-entity-region Clear a second-level cache entity region
doctrine:cache:clear-metadata Clears all metadata cache for an entity manager
doctrine:cache:clear-result Clears result cache for an entity manager
doctrine:cache:contains Check if a cache entry exists
doctrine:cache:delete Delete a cache entry
doctrine:cache:flush [doctrine:cache:clear] Flush a given cache
doctrine:cache:stats Get stats on a given cache provider
doctrine:database:create Creates the configured database
doctrine:ensure-production-settings Verify that Doctrine is properly configured for a production environment
doctrine:generate:crud [generate:doctrine:crud] Generates a CRUD based on a Doctrine entity
doctrine:generate:entity [generate:doctrine:entity] Generates a new Doctrine entity inside a bundle
doctrine:generate:form [generate:doctrine:form] Generates a form type class based on a Doctrine entity
doctrine:mapping:convert [orm:convert:mapping] Convert mapping information between supported formats
doctrine:mapping:import Imports mapping information from an existing database
doctrine:mapping:info
doctrine:schema:create Executes (or dumps) the SQL needed to generate the database schema
doctrine:schema:drop Executes (or dumps) the SQL needed to drop the current database schema

[...]

How can I do!?
What can I look for?

Thank ou in advance,
Oda

Reply
MolloKhan Avatar MolloKhan | SFCASTS | Oda | posted 1 year ago | edited

Hey Oda

That's weird! I can think of a couple of reasons:
1) You may have installed a very old version of the Doctrine bundle, so perhaps you could upgrade it and try again
2) Something weird happened when installing your vendors, try removing the vendor directory and run composer install

Cheers!

Reply

I was getting these errors with this command: ./bin/console doctrine:database:create

In AbstractMySQLDriver.php line 115: An exception occured in driver: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
In PDOConnection.php line 47: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'
In PDOConnection.php line 43: SQLSTATE[HY000] [1698] Access denied for user 'root'@'localhost'

And this worked for me:

$ sudo mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '<enter_a_password_here>';
mysql> exit
$ sudo service mysql stop
$ sudo service mysql start

make sure database_user in parameters.yml is root
make sure database_password in parameters.yml is the password you just set in mysql

$ ./bin/console doctrine:database:create
Created database `aqua_note` for connection named default

I found the solution here: https://stackoverflow.com/q...

Reply

Hey james-langridge

Easy and clear solution, great that you shared it!

Cheers!

Reply
Default user avatar
Default user avatar O.S.C.A.R | posted 3 years ago

Hey, I keep getting this error after following every step on the internet. I can connect to the MySql server using the command mysql -u root -p. when I run the "status" command I get the information that the user is root@localhost
But when i run the command: php bin/console doctrine:database:create, I keeping getting this error:

An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'db_user'@'localhost' (using password: YES).

This is my configuration file for doctrine.
app/config/packages/doctrine.yml:

parameters:
database_host: localhost
database_name: article_data
database_user: root
database_password: password
env(DATABASE_URL): 'mysql://%database_user%:%database_password%@localhost:3306/%database_name%'

doctrine:
dbal:
# configure these for your database server
server_version: '5.7'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci

url: '%env(resolve:DATABASE_URL)%'
orm:
auto_generate_proxy_classes: true
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
App:
is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity'
alias: App

would appreciate if someone can help me out.

Reply

Hey Oscar

For some reason you are trying to access to the DB as "db_user" user but in your parameters I see you defined "database_user" as "root". So, probably you are overriding the "database_user" parameter in somewhere. But, you should define an environment variable for your DB connection


// .env
DATABASE_URL=mysql://root:password@127.0.0.1:3306/db_name

Cheers!

Reply
Default user avatar

Hey, THANK YOU. I didn't check to see if the .env file existed so everytime I ran the database creation command, the default DATABASE_URL in the file was been used instead of the parameters I specified. Thanks so much.

1 Reply
Default user avatar

Hi,
I'm really new to Symfony and have been really enjoying these tutorials. I have come across a problem and was wondering if you can point me in the right direction. I am using Sqlite and had to do do a few things differently to create a table. Under app, resources, I created a database directory and within that a 'aqua_note_database' as a datasource. Ran the ./bin/console doctrine:database:create and yay it created a database. But when you did 'mysql -u root ...', i tried to compensate with 'sqlite -u root...' and it is not recognizing the command.

my question is, having to use sqlite, is the way I created a database ok? and what is the command for '-u root..'?

Thank you :)

Reply

Hi Claire!

Welcome to Symfony! :) You did a great job creating the database in sqlite. In fact, in the future, you might even be able to do a little less work - you shouldn't need to create the aqua_note_database file - Doctrine should even create that when you run doctrine:database:create :).

But anyways, one tricky thing with sqlite is that it doesn't have a fancy "mysql" command line tool. There a few GUI tools for visualizing an SQLite database (just google for them - I don't have a favorite, and they're dependent on your OS). OR, there is a better idea :). Symfony has an bin/console command that will make a raw SQL query for you. Try this:


bin/console doctrine:query:sql 'DESCRIBE genus'

It's not quite as convenient as the "mysql" utility, since you need to prefix everything with the "bin/console doctrine:query:sql", but it works awesome!

Let me know if it helps!

Reply
Default user avatar
Default user avatar Marcolic | posted 4 years ago

Hello everyone. I used to use wamp for development, everything I know is self learning and I only dev for my pleasure.

I'm using the server that symfony provides. I installed MySql, the database have been created and it seem to be working. The only thing is that I can't use 'mysql' as a command line so I tried to add that path:"C:\Program Files\MySQL\MySQL Server 5.7\bin" to my environnement variables but it still doesn't work. Any idea ? Btw I'm on Windows 8.1.

Reply

Hi there!

I'm not *too* good with Windows, unfortunately :). But, I can tell you that you should be able to execute the mysql command using the *long* version, even if your path isn't setup correclty:

C:\Program Files\MySQL\MySQL Server 5.7\bin\mysql

Also, you can cheat! Symfony has a console command that allows you to run queries through it:

php bin/console doctrine:query:sql "DESCRIBE genus"

I hope that helps!

Reply
Default user avatar

ok. I found what was my problem. The thing is I'm using cmder and I thought it was able to read path variables, which is not true. I just add to create aliases. Anayway thanks for your answer Ryan.

Reply
Default user avatar
Default user avatar dev_lime | posted 4 years ago

I've wandered off the beaten path a little and managed to get...not an error as such (Techincally) But I am getting this "No Metadata Classes to process."... any ideas? This is my PHP

Reply
Default user avatar

namespace AppBundle\Entiry;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
* @ORM\Table(name="posts")
*/
class Posts {

/**
* @ORM\Id
* @ORM\GeneratedValue(stratergy="AUTO")
* @ORM\Column(type="interger")
*/
private $id;

/**
* @ORM\Column(type="string")
*/
private $name;

Reply
Default user avatar

I'm guessing it can't spot my variables... but I have no idea how to resolve this >.>

Reply

Yo!

Yep, you're thinking about it correctly. I'm guessing you get this error if you run the doctrine:schema:update command, or generally try to do anything related to Doctrine? Here's how it works:

1) When the system loads, Doctrine needs to know about *all* of the entities in the system.
2) By default, it looks in the Entity directory of all of your bundles and looks inside any classes there for the annotations

So, the error you're getting is basically Doctrine saying "Hi! I don't see any annotated classes in your Entity directory".

So, a few things to check for:

1) Make sure you have the <?php tag in your Entity class. This sounds silly - but it's actually the most common thing to forget :)

2) Make sure your directory is called Entity exactly

3) Though I would have expected a different error, you do have a typo in your namespace - you have Entiry - change that to Entity :).

Let me know how it goes!

Reply
Default user avatar

Ah, man! A cliff hanger!! Any chance I can get the rest of your thoughts on this? :p Glad to see I was on the right path, anyway ^_^

Reply

Oh man, lame! I didn't realize my message got cut off! I just updated it above - my <php killed the message at first :).

Glad you got it working - and good working using PhpStorm :)

Reply
Default user avatar

Hi peons :),

Is there a way to change the default behaviour of Doctrine and make it look in another directory than "Entity".
I mean I want my enteties Classes in another directory...
I tried the mapping options but it didn't do the job.
May
you provide an exemple of the config portion of the Doctrine mapping I
could use to tell doctrine than the entity classes are not in the
default 'Entity' directory. The one that should be in :
./src/AppBundle/Entity

But look in another directory let's say :
./src/AppBundle/LetsSayMyEntity

I tried this :

doctrine:

[...]

orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
mappings:
AppBundle:
mapping: true
type: annotation
dir: LetsSayMyEntity
alias: AppBundle

Thank you all !

Reply

Hey Abou

Is totally possible what you want to achieve, actually there are two ways you can do it, changing the mapping inside a bundle (your case), or outside a bundle
I'll leave you here the link to the docs if you want to dive deeper http://symfony.com/doc/curr...

For your case, you will have to do something like this:


// config.yml
doctrine:
orm:
auto_mapping: true
mappings:
AppBundle:
type: annotation
dir: LetsSayMyEntity


In this case, doctrine will look inside AppBundle/LetsSayMyEntity folder

I hope it helps you :)
Cheers!

Reply
Default user avatar

Hi diego,

Thank you for your answer !

But the snippet of code you gave me is the exact same code I posted as tryed. It doesn't do the job as I said...

Do you have any idea of what could be wrong, maybe elsewhere my implementation ?...

Reply
Default user avatar

Ah... I think I shouldn't use 'auto_mapping' set to 'true'... I'll give it try later ;)

Thank's all
:)

Reply

I don't think that's the case, because below that, you are overriding the default values

Reply

Oh sorry, it is kind of dificult to see without a format :)

Hmm, it should work that way, check that you are using the right namespaces for your entities
You could try to use the other type of configuration, outside of a bundle http://symfony.com/doc/curr...

Reply
Default user avatar

Don't worry. What ever I did fixed it. I think it helps that I'm using PHPstorm now, too =p

Reply
Default user avatar
Default user avatar Marco La Cugurra | posted 4 years ago

Hello as I launch the ./bin/console doctrine:database:create I get this error :"[Doctrine\DBAL\Exception\ConnectionException]

An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused

[Doctrine\DBAL\Driver\PDOException]

SQLSTATE[HY000] [2002] Connection refused

[PDOException]

SQLSTATE[HY000] [2002] Connection refused

"
Can someone help me out with that? I guess there are probably some problems with my parameters. I'm not using MAMP by the way.
this are my parameters:

parameters:
database_host: 127.0.0.1
database_port: ~
database_name: aqua_note
database_user: root
database_password: null
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
secret: 03b3f955112e8fd6629f3379f556cd72c9008251

Reply

Hey Marco!

Hmm, connection refused us when there is no database running on the server. Do you have MySQL installed? Alternatively, you could use Sqlite, which doesn't require to have a database running. There are instructions in the config.yml file for how to use Sqlite, but here is a gist if it helps: https://gist.github.com/wea.... But, installing/starting MySQL is also a good idea :).

Cheers!

Reply
Default user avatar
Default user avatar Marco La Cugurra | weaverryan | posted 4 years ago

Hello,
I guess I installed mySQL now I'm getting a different error

[Doctrine\DBAL\Exception\ConnectionException]

An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: NO)

some help anyone please :)
thank you

Reply

Hey Marco!

Ah, this is a good step forward! The database is now running, and you're using the user "root", but the password is incorrect. The correct password depends on how you installed mysql - a common option is either a blank password (that's the default in parameters.yml) *or* "root" also for the password. Check the documentation for how you installed it and then update parameters.yml and try again.

You're close!

Reply
Default user avatar

After fighting with the same error as Marco and not finding a solution, I thought I'd share mine here:
I am running Symfony from Ubuntu, and in the parameters.yml file, I actually needed to specify the Ubuntu root password that I had set on initializing the OS. So that row in parameters.yml is not set to null, but looks something like this:
database_password: XYZ123
Hope I could help some fellow newbies.

Reply

Thanks for sharing Andrea! The password is *usually* null on MySQL installs... but certainly not always - an important detail indeed!

Reply
Default user avatar
Default user avatar Yoni L. | posted 4 years ago

Hi thank you for this, is there any problem to use utf8mb4 charset, in annotation i found that you can add collation info in table annotation like this:
@ORM\Table(name="genus", options={"collate"="utf8mb4_general_ci", "charset"="utf8mb4"})
is it a good practice or some kind of black magic?

Reply

Hi Yoni!

I don't see any problem with this. In fact, it's important to make sure that your tables use utf8 in the beginning (changing them later is a pain!). I usually create my database with a utf8 charset, and then let my tables inherit that from the database. However, if you do what you have here, then you will definitely not have any problems.

But actually, you can also set this globally. See the "Setting up the Database to be UTF8" title under this section: http://symfony.com/doc/curr...

That's the way to go :)

Cheers!

Reply
Default user avatar

Hi there,

I am getting this error every time I run $ ./bin/console doctrine:database:create

[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[HY000] [2002] Connection refused

[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [2002] Connection refused

[PDOException]
SQLSTATE[HY000] [2002] Connection refused

doctrine:database:create [--shard SHARD] [--connection [CONNECTION]] [--if-not-exists] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

However, my configurations are as follow below;

config.yml

# Doctrine Configuration
doctrine:
dbal:
default_connection: default
connections:
default:
driver: pdo_mysql
dbname: "%database_name%"
user: "%database_user%"
host: "%database_host%"
password: "%database_password%"
unix_socket: /tmp/mysql.sock
charset: UTF8

parameters.yml

parameters:
database_host: 127.0.0.1
database_port: null
database_name: aqua_note
database_user: root
database_password: null
secret: 0b719bbdb89bd1ce9774b1069c9696d8ce3f1b08

mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: ~
mailer_password: ~

Can someone please help? I will really appreciate it.

Thanks!

Reply
Default user avatar

btw the yml files are properly indented.

Reply
victor Avatar victor | SFCASTS | fmm8 | posted 4 years ago | edited

Hey fmm8 ,

There're could be a few reasons, but the all of them are related to invalid DB credentials. Please, double check your MySQL credentials like port, login, password, etc. Is your MySQL server running? Have you tried successfully to connect to the MySQL database in other project? Or probably connection to a DB with PhpMyAdmin, MySQL Workbench or similar utility? Which credentials do you use there?

Cheers!

-1 Reply
Default user avatar
Default user avatar Ali Niaki | posted 4 years ago

Hey there,
so I've got a problem, when I run:
./bin/console doctrine:database:create
I get:
[Doctrine\DBAL\Exception\DriverException]
An exception occured in driver: could not find driver

[Doctrine\DBAL\Driver\PDOException]
could not find driver

[PDOException]
could not find driver

I just need to mention that I have other projects on my system and they are all working fine with msql.
I mean php7.0-mysql is installed and working.
I'll be glad if anyone can help me with this.

Reply
Default user avatar

OK! this is wired. I installed:
sudo apt-get install php-mysql
and everything is working now!!
but...
what is the difference between "php7.0-mysql" and "php-mysql" ?!?! Why I can have both installed at the same time!

and then...
I was using MYSQL Workbench before, and I have a connection to to the localhost. There are 3 databases there and I just added anotherone using symfony's Doctrine.

However, I can't see it with MYSQL Workbench, but when I check it through the terminal, it's there! :|
what is going on?! :))

BTW, I'm still getting this error when I try to put some data in the database from a controller:
Uncaught PHP Exception Doctrine\DBAL\Exception\DriverException: "An exception occured in driver: could not find driver

Reply
Cat in space

"Houston: no signs of life"
Start the conversation!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*", // v3.1.4
        "doctrine/orm": "^2.5", // v2.7.2
        "doctrine/doctrine-bundle": "^1.6", // 1.6.4
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.0
        "symfony/swiftmailer-bundle": "^2.3", // v2.3.11
        "symfony/monolog-bundle": "^2.8", // 2.11.1
        "symfony/polyfill-apcu": "^1.0", // v1.2.0
        "sensio/distribution-bundle": "^5.0", // v5.0.22
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.16
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.2
        "composer/package-versions-deprecated": "^1.11", // 1.11.99
        "knplabs/knp-markdown-bundle": "^1.4", // 1.4.2
        "doctrine/doctrine-migrations-bundle": "^1.1" // 1.1.1
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.0.7
        "symfony/phpunit-bridge": "^3.0", // v3.1.3
        "nelmio/alice": "^2.1", // 2.1.4
        "doctrine/doctrine-fixtures-bundle": "^2.3" // 2.3.0
    }
}