Reputation:
I am trying to set up two environments: local and production.
So far, I have added a bootstrap/environment.php
file which is:
$env = $app->detectEnvironment(array(
'local' => array('Ben'),
'staging' => array('staging.domain.org'),
'production' => array('domain.org'),
));
and two .env
files - .local.env
and .production.env
with the different environment variables such as: APP_ENV=local
and APP_DEBUG=true
.
My laptop's hostname is called Ben
.
The problem I'm having is the php artisan env
always returns Production
and thus, I can't load my application.
Also, within the production.env
file, if I change the APP_DEBUG
variable to true or false, it doesn't make a difference on the web application - it always returns "Whoops, looks like something went wrong.".
Any help would be greatly appreciated. Thank you.
Upvotes: 3
Views: 6469
Reputation: 1
Go to your .env file in laravel and set your
PAYTM_ENVIRONMENT=production
PAYTM_MERCHANT_ID={// Your production MID}
PAYTM_MERCHANT_KEY={// Your production Merchant key}
PAYTM_MERCHANT_WEBSITE=DEFAULT
PAYTM_CHANNEL=WEB
Upvotes: 0
Reputation: 11
For Laravel >= 5.1
It's because your environment is configured wrong or your .env file was not correctly set.
Try this
php artisan config:clear
Maybe that help you.
Regards!
Upvotes: 1
Reputation: 569
I had that problem. I am using Laravel 5.2.14 with homestead. I fixed the problem adding this line:
'env' => env('APP_ENV', 'production'),
in the file: config\app.php
I upgraded my Laravel app from a previous version which did not contain that line or at least I did not have it. Latest file version in:
https://github.com/laravel/laravel/blob/master/config/app.php
Upvotes: 12
Reputation: 1648
This bugged the hell out of me in Laravel 5. The way I fixed it was by adding the following to the end of bootstrap/app.php:
$app->detectEnvironment(function () use($app) {
$env = env('APP_ENV', 'local');
$file = ".env.{$env}";
$app->loadEnvironmentFrom($file);
});
Then add files for each environment, e.g. .env.local, .env.production etc.
You can now swicth environment files by setting the APP_ENV environment variable. The code defaults to '.env.local' if APP_ENV is not set. Test this works with:
$ APP_ENV=production ./artisan env
Current application environment: production
$ ./artisan env
Current application environment: local
Laravel automatically sets APP_ENV to 'testing' when running phpunit (specifically in the Foundation/Testing/TestCase class), so make sure you have a '.env.testing' file if you want to use different database settings etc when running tests.
Upvotes: 2
Reputation: 219930
The bootstrap/environment.php
file is not loaded in Laravel 5.1 anymore. Laravel does not load different env
files depending on the environment.
Laravel now only loads a single .env
file. This file should not be in your version control. For your production server, you'll simply put different values into the .env
file.
For more information, read the docs.
Upvotes: 2