# Configuration Best Practices ## Read Environment Variables in Configuration Files Call ___SINGLE_BACKTICK___env()___SINGLE_BACKTICK___ only from configuration files. After configuration is cached, Laravel does not load the application's ___SINGLE_BACKTICK___.env___SINGLE_BACKTICK___ file, so application code should read configuration values through ___SINGLE_BACKTICK___config()___SINGLE_BACKTICK___. Incorrect: ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___php $key = env('API_KEY'); ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___ Correct: ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___php // config/services.php return [ 'key' => env('API_KEY'), ]; // Application code $key = config('services.key'); ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___ ## Protect Production Secrets Do not commit plaintext production secrets. Laravel can encrypt an environment file so its encrypted form can be stored safely, while deployment platforms can supply secrets through their native secret stores. Incorrect: ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___bash # A plaintext .env file committed to the repository STRIPE_SECRET= AWS_SECRET_ACCESS_KEY= ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___ Encrypted environment file: ___SINGLE_BACKTICK______SINGLE_BACKTICK______SINGLE_BACKTICK___bash
Fatal error: Uncaught Error: Call to undefined function e() in /home13/settlepos/restaurant.settlepos.com/storage/framework/views/11f2693d1fb336d7fb5ec82856c5a9ad.php:43 Stack trace: #0 {main} thrown in /home13/settlepos/restaurant.settlepos.com/storage/framework/views/11f2693d1fb336d7fb5ec82856c5a9ad.php on line 43