故障排除“没有这样的文件或目录"运行`php app/console 原则:模式:创建` [英] Troubleshooting "No such file or directory" when running `php app/console doctrine:schema:create`
问题描述
我是 Symfony2 (beta4) 和 Doctrine 的新手,当我尝试通过命令行创建数据库架构时遇到了问题.
I am new to Symfony2 (beta4) and Doctrine and am having issues when i try to create the DB schema via command line.
错误如下:
$ 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 数据库设置正确插入到 config/parameters.ini 文件中.
The mysql database settings are correctly inserted in the config/parameters.ini file.
这是 config.yml 中的 Doctrine 配置
And here's the Doctrine configuration in 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
和实体(我只做了一个来测试它)
And the entity (i made only one to test it)
<?php
// src/Acme/NewsBundle/Entity/Article.php
namespace AcmeNewsBundleEntity;
use DoctrineORMMapping as ORM;
/**
* @ORMEntity
* @ORMTable(name="articles")
*/
class Article
{
/**
* @ORMId
* @ORMColumn(type="integer")
* @ORMGeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORMColumn(type="string", length="255")
*/
protected $title;
/**
* @ORMColumn(type="text")
*/
protected $body;
/**
* @ORMColumn(type="string", length="255")
*/
protected $author;
/**
* @ORMColumn(type="date")
*/
protected $date;
}
?>
推荐答案
我按照这个小教程修复了它:http://andreys.info/blog/2007-11-07/configuring-terminal-to-work-with-mamp-mysql-on-leopard
I fixed it by following this small tutorial: http://andreys.info/blog/2007-11-07/configuring-terminal-to-work-with-mamp-mysql-on-leopard
:我修改了正确的 php.ini,现在一切正常.
现在我收到以下错误:
[Exception]
DateTime::__construct(): It is not safe to rely on the system's timezone settings.
You are *required* to use the date.timezone setting or the date_default_timezone_set() function.
In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
We selected 'Europe/Berlin' for 'CEST/2.0/DST' instead
这是 php.ini 中的 date.timezone 配置
Here's the date.timezone config in php.ini
date.timezone = "Europe/Paris"
我会尝试自己解决这个问题,但如果你们中的任何人知道如何解决它,请不要犹豫对此发表评论.谢谢!
I'll try to figure it out myself but if any of you know how to fix it don't hesitate to comment on this. Thanks!
这篇关于故障排除“没有这样的文件或目录"运行`php app/console 原则:模式:创建`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!