Laravel artisan always thinks its in local

2019-09-07 21:48发布

I set several ENV variables with Laravel Forge which are correctly picked up by the application. However artisan doesn't seem to pick up my environment. php artisan env returns:

Current application environment: local

In the nginx configuration I also have

fastcgi_param ENV "test";

This is how I detect my environment:

$env = $app->detectEnvironment(function () {
    return getenv('ENV') ?: 'local';
});

How can I have artisan think its in the test environment?

2条回答
forever°为你锁心
2楼-- · 2019-09-07 22:40

Go to your laravel forge site and click on 'Edit Deploy Script'.

Change line 4 to

php artisan migrate --env=production

or whatever env you need.

You will need to do the same when running an artisan command in the console.

php artisan <command> --env=test
查看更多
Ridiculous、
3楼-- · 2019-09-07 22:45

Try to verify if your .env file is correctly configured. Take a look in your .env and set this:

APP_ENV=test

after that try to clear your configuration. Type this in your terminal:

php artisan config:clear

and to finish verify your environment with this:

php artisan env

I hope this help you.

Regards!

查看更多
登录 后发表回答