Questions tagged [laravel-environment]

Setting up Laravel environments and using .env files in Laravel

24 questions
29
votes
5 answers

What's the correct way to set ENV variables in Laravel 5?

In laravel 4 we had: $env = $app->detectEnvironment(array( 'local' => array('homestead') )); by default. But in laravel 5 it's changed to: $env = $app->detectEnvironment(function() { return getenv('APP_ENV') ?: 'production'; }); Also, they…
Alexander Kim
  • 17,304
  • 23
  • 100
  • 157
12
votes
4 answers

Laravel 5 configuration - environments and overriding

I installed fresh Laravel 5 copy. My detectEnvironment function is defined this way: $app->detectEnvironment(function() { return 'local'; return getenv('APP_ENV') ?: 'production'; }); In config\local I've created database.php…
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
4
votes
4 answers

Laravel 5 Dotenv for specific subdomain

I have a few subdomain in my laravel 5 application, each sub domain have a specific configuration, like mail, nocaptcha, etc. how to set .env file to work with my-specific subdomain ?
comenk
  • 43
  • 1
  • 4
3
votes
4 answers

How would you skip Laravel Scout if enviroment is not production?

I have an app that I am writing with Laravel. I am still fairly new with the framework and don't understand most of it. I am using Algolia as the search engine with Laravel's Scout. In the models you add use Searchable, a trait, and the records…
Chris Edwards
  • 454
  • 1
  • 9
  • 22
2
votes
1 answer

How to access storage file from .env file in Laravel

I created a JSON file to use BigQuery in my Laravel project => BigQuery docs. I put the file in the storage folder to limit its access. I only need to access it from my .env file. GOOGLE_APPLICATION_CREDENTIALS='/storage/file.json' Naturally, I…
2
votes
1 answer

How to get or set `env` different value from a user in Laravel Controller

I am trying to set some of ENV values from the user end dynamically. I want to use multiple sms gateway services so that user can use any one from multiple gateways. Multiple services have different api, sid or token. I am saving these service…
1
vote
1 answer

How to load custom .env file in Laravel console command?

I have this console command code: class MyCommand extends Command { protected $signature = 'custom:mycommand {domain}'; // ... public function handle() { $domain = $this->argument('domain'); // read domain based…
netdjw
  • 5,419
  • 21
  • 88
  • 162
1
vote
4 answers

Laravel ENV not reload

I use Laravel 6.2 with valet and PHP 7.3.12 The problem is I want to change DB_DATABASE=laravel to DB_DATABASE=something_else in .env file but it doesn't reload the new .env value at all I have already tried this command: php artisan…
Ch.Suparerk
  • 39
  • 1
  • 8
1
vote
1 answer

Laravel encryption key "disappears" on page load

I have some trouble with Laravel and Ajax that I haven't been able to Google or Stackoverflow my way out of. Whatever solutions I've seen, I've already accounted for. Sporadically I'm getting a 500 error (sometimes it's 401). It only happens with…
1
vote
2 answers

Laravel 5.2 is not reading from .env on ubuntu

Note: This question is not a duplicate of these questions: Laravel 5.2 not reading env file Laravel 5.2 .env sometimes doesn't load in time I'm getting this error: production.ERROR: exception 'RuntimeException' with message 'No supported…
1
vote
1 answer

Laravel 4.2 using Apache Dev and Production Subdomains

I need to setup a development and production environment using subdomains with Laravel and Apache. For example: dev.mydomain.com app.mydomain.com Where app is production and dev is development. Inside of my /var/www I have the folders…
adam2k
  • 369
  • 5
  • 14
0
votes
0 answers

No data displayed to the frontend from observer - Laravel

I want to output user activity history. Here's observer that i want to output message of user activity to my front end if($drop_student){ Logger::createLog("Student Schedule Removed for ". $student->first_name . " " . $student->last_name . " '" .…
Kael
  • 161
  • 2
  • 13
0
votes
1 answer

Npm run prod with Laravel Mix and localhost:8080

I would like to know how I can use APP_URL from my .env file in the layout. Currently, I have the following.
0
votes
1 answer

Still sending emails to old Mailtrap settings in Laravel

I'm trying to send test emails to my newly created Mailtrap inbox, but the problem I'm having is that nothing gets sent to that inbox, and when I check my log file, I have the following. local.ERROR: Failed to authenticate on SMTP server with…
Aurilie
  • 189
  • 3
  • 14
0
votes
1 answer

Laravel - Catch php artisan commands

I've did some changes in my config/app to use multiple databases selected by front-end, now I have to tell in \Request()->header('database') which database I want access. It's work perfectly, the problem is: when I try to do any artisan commands my…
1
2