对运行“php app/console doctrine:schema:create”时“没有这样的文件或目录”进行故障排除
2022-08-30 11:45:13
我是Symfony2(beta4)和Tructions的新手,当我尝试通过命令行创建DB模式时遇到了问题。
这是错误:
$ php app/console doctrine:schema:create
Creating database schema...
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
[ErrorException]
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)
in /Applications/MAMP/htdocs/sf-test-2/vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php line 36
mysql 数据库设置已正确插入到配置/参数.ini文件中。
这是config.yml中的教义配置
# Doctrine Configuration
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
dbname: %database_name%
user: %database_user%
password: %database_password%
orm:
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
和实体(我只做了一个来测试它)
<?php
// src/Acme/NewsBundle/Entity/Article.php
namespace Acme\NewsBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="articles")
*/
class Article
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length="255")
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
protected $body;
/**
* @ORM\Column(type="string", length="255")
*/
protected $author;
/**
* @ORM\Column(type="date")
*/
protected $date;
}
?>