Tech
Laravel env() Outside config/: Catch Deployment Bugs Before config:cache
The bug only appears after configuration caching
A Laravel application can behave perfectly during development and then fail after deployment because a service class reads an environment variable directly:
// app/Services/AcmeClient.php
$token = env ( 'ACME_TOKEN' );
Laravel's configuration cache changes the boot process. Once configuration has been cached, the framework does not load the application's .env file for normal requests or Artisan commands. A direct...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to