I started learning Symfony2 and I wanted to use Doctrine to create table in my postgres database. I installed postgres and followed this steps:
sudo -i -u postgres
I've created user with name: test and type superuser
createuser --interactive
createdb test
I created user test with password test
adduser test
And my parameters.yml in symfony2 looks like this:
parameters:
database_driver: pdo_pgsql
database_host: 127.0.0.1
database_port: null
database_name: test
database_user: test
database_password: test
mailer_transport: smtp
mailer_host: 127.0.0.1
mailer_user: null
mailer_password: null
Also I have entity like this:
<?php
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="product")
*/
class Product
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100)
*/
protected $name;
/**
* @ORM\Column(type="decimal", scale=2)
*/
protected $price;
/**
* @ORM\Column(type="text")
*/
protected $description;
}
Then I typed this commend in terminal:
php app/console doctrine:generate:entities AppBundle
And I got this warning:
[Doctrine\DBAL\Exception\ConnectionException]
An exception occured in driver: SQLSTATE[28000] [1045] Access denied for us
er 'test'@'localhost' (using password: YES)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[28000] [1045] Access denied for user 'test'@'localhost' (using pas
sword: YES)
[PDOException]
SQLSTATE[28000] [1045] Access denied for user 'test'@'localhost' (using pas
sword: YES)
What can I do to solve this problem?
EDIT:
I realized that I'm connected to mysql database and I don't know why. How can I change this?
config.ymlfile and more specifically the part where your configure thedoctrinedbal connection. You can use the official documentation to see what config does what.