Mahmoud Al-HabashOpen to new projects
  • WorkWork
  • ServicesServices
  • LabLab
  • WritingWriting
  • ContactContact
Amman--:--عربي
Writing/Laravel

Laravel Config and Environment Variables

Manage configuration and environment variables properly.

16 January 20261 min readLaravelاقرأ بالعربية

On this page

  1. Access Config
  2. Environment Variables
  3. Custom Config File
  4. Config Caching
  5. Runtime Setting

Configuration management:

Access Config

php
$value = config('app.name');
$value = config('app.timezone', 'UTC');

Environment Variables

php
$debug = env('APP_DEBUG', false);

Custom Config File

// config/services.php
return [
    'stripe' => [
        'key' => env('STRIPE_KEY'),
    ],
];

Config Caching

php artisan config:cache
php artisan config:clear

Runtime Setting

config(['app.timezone' => 'Asia/Dubai']);
All articles

Keep reading

  • Laravel Action Classes Pattern16 January 20261 min read
  • Laravel Action Classes: Single Responsibility16 January 20261 min read
  • Laravel API Rate Limiting16 January 20261 min read