1

Recently I started working with Symfony. I created a project with the terminal/composer under the name "symfony" and also created a database on phpmyadmin (MAMP) which I called "symfony". I installed the project, and except a error of my timezone, my project was succesfully created and was running at my localhost.

After that I created a bundle called "SymfonyCinemaBundle" and my bundle was generated succesfully. I also tried to generate a entity but that is not working for me, and also the problem. After I open up the generator with the command, It asks for a shortcut name and I tried to use "SymfonyCinemaBundle:Movie" but that isn't working and gives me the following error:

*The Entity shortcut name: SymfonyCinemaBundle:Movie

[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:generate:entity [--entity ENTITY] [--fields FIELDS] [--format FORMAT] [--with-repository]*

I checked my parameters.yml but thats seems to be right. I've looked on the internet but nothing seems to help unfortunately. Does anyone has a solution for me?

Note: I'm using MAMP. The difference between normal and developers mode has no difference.

4

1 回答 1

2

解决了:

我已将 parameters.yml 中的主机更改为 localhost 而不是 127.0.0.1。我还添加了正确的端口号(通常没关系),这解决了问题,但给了我另一个错误:“没有这样的文件或直接”。它与我的 mysql.sock 有关,所以我在终端中使用了以下命令:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock
sudo chown _mysql /var/mysql/mysql.sock
sudo chmod 777 /var/mysql/mysql.sock
于 2015-10-30T13:23:51.227 回答