LoadEnvironmentVariables reads .env with phpdotenv 13,554 (github.com/vlucas/phpdotenv (https://github.com/vlucas/phpdotenv 13,554 )). Commit .env.example, never .env; a real server or shell variable always beats the file. Values are strings except the reserved true, false, null and empty (also in parentheses), which env() converts. With BOOKSHOP_FREE_SHIPPING_OVER=150, BOOKSHOP_REVIEWS_ENABLED=true and BOOKSHOP_BANNER=(empty) in .env:
php artisan tinker --execute 'var_dump(env("BOOKSHOP_FREE_SHIPPING_OVER"),
env("BOOKSHOP_REVIEWS_ENABLED"), env("BOOKSHOP_BANNER"), env("SESSION_DOMAIN"),
env("BOOKSHOP_TAX", 0.08));'string(3) "150" bool(true) string(0) "" NULL float(0.08)
When APP_ENV is set outside the file or you pass --env=staging, Laravel 2,157 loads .env.staging if it exists: php artisan env --env=staging printed "The application environment is [staging]." Test it in code with app()->environment('local') or app()->isProduction(). php artisan env:encrypt --env=staging writes an AES-256-CBC .env.staging.encrypted that is safe to commit and prints its key; env:decrypt --key=... restores it. Call env() only inside config/*.php (Config and Route Caching shows why).