Artisan无法使用数据库配置文件中的$ _SERVER变量

I am currently deploying a Laravel project on my shared hosting account. It is an open project and hosted on GitHub as a public repository. As a result I'm using dynamic variables set by an .htaccess file in my database.php configuration file for my production environment. This allows me to also update my deployment using a git pull command on my host which helps speed up work.

The database.php file has something similar to

$database = $_SERVER['DBNAME'];

$database_user = $_SERVER['DBUSER'];

This is much like what is done when deploying to PagodaBox & works perfectly fine for the application with all things functioning as expected in the browser, no complaints.

The problem I have is that artisan is unable to use these variables and will attempt instead to connect to the database using what I believe to empty variables when processing a migrate instruction. I get an error that artisan tried to connect to the databases with no password. I have been calling artisan using --env=production and have tested this but found that it will only work if the database.php file has the variables specified explicitly instead of as environment variables.

Is there a way of causing artisan to "see" these environment variables?


answers that have proved useful to me so far:

http://forums.laravel.io/viewtopic.php?pid=8455

and

Environment driven database settings in Laravel?

查看全部
dtyqflrr775518
dtyqflrr775518
2013/01/19 07:51
  • laravel
  • environment
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复