在生产服务器上配置symfony项目时遇到问题。当我运行命令doctrine --build --all --and-load时,它会让我在生产环境中出错:
>> doctrine Dropping "doctrine" database PHP Notice: Undefined index: dbname in /var/www/sf_project/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 1472 Notice: Undefined index: dbname in /var/www/sf_project/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 1472 >> doctrine SQLSTATE[42000]: Syntax error or access violation: 1064 You have an erro...e right syntax to use near '' at line 1. Failing Query: "DROP DATABASE " >> doctrine Creating "dev" environment "doctrine" database PHP Notice: Undefined index: dbname in /var/www/sf_project/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 1439
但是在错误之后它成功创建了表。但是,如果我第二次运行该命令,则在创建表时会部分失败。
我已经为生产环境正确更改了我的database.yml配置。这是:
all: doctrine: class: sfDoctrineDatabase param: dsn: mysql:host=localhost;dbname=sf_project port: 3306 username: root password: mainserver
虽然它在当地环境中正常工作。 有人可以对此有所了解吗?
编辑注释:将“/cache//prod/config/config_databases.yml.php”文件的内容添加为“xzyfer”建议。
以下是内容:
return array( 'doctrine' => new sfDoctrineDatabase(array ( 'dsn' => 'mysql:host=localhost; dbname=sf_project', 'port' => 3306, 'username' => 'root', 'password' => 'mainserver', 'name' => 'doctrine', )),);
答案 0 :(得分:1)
尝试:
./symfony doctrine:build --all --and-load --env=prod