🔴 Laravel
Beginner
What is the config() helper in Laravel?
Answer
The config() helper accesses configuration values from the files in the config/ directory using dot notation. config("app.name") reads the name key from config/app.php. config("database.connections.mysql.host") reads a nested value. Provide a default: config("app.locale", "en"). Set at runtime: config(["app.locale" => "fr"]) (only for the current request). Configuration files read environment variables via env() — but in application code, always call config(), not env() directly, because configuration values are cached with php artisan config:cache, and env() returns null in a cached environment. Clear config cache: php artisan config:clear.