Laravel Application未检测到环境变量

时间:2014-07-07 18:29:41

标签: php google-app-engine laravel laravel-4

我试图在谷歌云上部署我的应用程序,但遇到了一些麻烦。

在我的app.yaml中我有

    env_variables:
# change these values as appropriate:
 DEVELOPMENT_DB_HOST: '***'
 DEVELOPMENT_DB_USERNAME: '***'
 DEVELOPMENT_DB_PASSWORD: '***'
 DEVELOPMENT_USER_DB_NAME: '***'
 PRODUCTION_CLOUD_SQL_INSTANCE: '****'
 PRODUCTION_DB_USERNAME: '***'
 PRODUCTION_DB_PASSWORD: '***'
 PRODUCTION_USER_DB_NAME: '***'

在我的database.php中,我有这个if子句:

if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App    Engine') !== false) {
  $user_array = array(
        'driver'        =>  'mysql',
        'unix_socket'   =>  getenv('PRODUCTION_CLOUD_SQL_INSTANCE'),
        'host'          =>  '',
        'database'      =>  getenv('PRODUCTION_USER_DB_NAME'),
        'username'      =>  getenv('PRODUCTION_DB_USERNAME'),
        'password'      =>  getenv('PRODUCTION_DB_PASSWORD'),
        'charset'       =>  'utf8',
        'collation'     =>  'utf8_unicode_ci',
        'prefix'        =>  ''
    );
} else {
  $user_array = array(
        'driver'    => 'mysql',
        'host'      => getenv('DEVELOPMENT_DB_HOST'),
        'database'  => getenv('DEVELOPMENT_USER_DB_NAME'),
        'username'  => getenv('DEVELOPMENT_DB_USERNAME'),
        'password'  => getenv('DEVELOPMENT_DB_PASSWORD'),
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    );
} 

由于某种原因,当我尝试在本地计算机上运行迁移时,未检测到环境变量。会导致这种情况的原因。

更新

这是我的终端显示的内容 click here

1 个答案:

答案 0 :(得分:1)

app.yaml中指定的环境变量仅在dev_appserver环境中使用和设置。我假设你使用标准的php-cgi来运行artisan,它不懂app.yaml。