$env = $app->detectEnvironment(function()
{
return getenv('APP_ENV') ?: 'local';
});
If APP_ENV variable exists, use that, if not, use 'local'
Of course you have to set the APP_ENV in Forge.
pogachar said: Of course you have to set the APP_ENV in Forge.
Well still not working with Forge. These are in my nginx config script
fastcgi_param APP_ENV "production";
fastcgi_param ENV "production";
forge@Fitness:~/default$ php artisan queue:work
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
Also
forge@Fitness:~/default$ php artisan queue:work --env=production
[PDOException]
SQLSTATE[HY000] [2002] Connection refused
I am struggling with this issue too. It was working with setting the --env before, but not anymore.
Could you check what "php artisan env" gives you?
I get "local" even I set those in ngix.
fastcgi_param ENV "production"; fastcgi_param LARA_ENV "production";
here is my start.php
$env = $app->detectEnvironment(function() {
if (getenv('LARA_ENV')) {
return getenv('LARA_ENV');
} else {
return 'local'; // Or whatever your default is
}
});
I get production but still connection refused.
I wonder why no one knows the answer to this basic question!
Environment variables set in nginx won't work on command line. Use the --env=whatever
artisan option.
valorin said:
Environment variables set in nginx won't work on command line. Use the
--env=whatever
artisan option.
I am using Forge's queue workers screenshot. There is no place to use --env=whatever!
Also look at post number 1
forge@Fitness:~/default$ php artisan queue:work --env=production
[PDOException] SQLSTATE[HY000] [2002] Connection refused
Jesus someone answer this it's been a week!
No one is going to bother helping you if you are rude and offensive.
"Connection refused" means your database credentials are wrong. Check your config and credentials are valid...
valorin said:
No one is going to bother helping you if you are rude and offensive.
"Connection refused" means your database credentials are wrong. Check your config and credentials are valid...
valorin, who's been rude bro?
Database credentials are set in Froge. They should be right since the website is working, no?
Peace, love and cuddles
I don't have a Forge account to check, but is it possible it's using Environment Variables to set the db credentials maybe?
Worst case scenario, delete the VM, and re-create it from scratch. Something might've gone weird during the set up process.
valorin said:
I don't have a Forge account to check, but is it possible it's using Environment Variables to set the db credentials maybe?
Worst case scenario, delete the VM, and re-create it from scratch. Something might've gone weird during the set up process.
Hey;
Forge allows you to set ENV variables. But apparently they are not the ones that Artisan uses.
Not sure why there are no docs on this!
Hey @behnampmdg3 ran into the same issue and found Matt Stauers post, he says:
However, based on some of my experiences with queues and other aspects of Forge, I'd still highly recommend you use the associative array form of environment detection rather than using a Closure
Basically with Forge you need to be more explicit with your environment. Instead of using an environment var to detect, you'll want to use your production server hostname:
$env = $app->detectEnvironment(array(
'production' => array('your-server-hostname'),
'local' => array('homestead', '.local')
));
http://mattstauffer.co/blog/laravel-forge-using-environment-variables-for-environment-detection
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community