WEB DEVELOPER SITE
TUTORIALS HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

Laravel - Configuration


basic design documents of Laravel are incorporated into the config directory.

Environment Configuration

Environment factors are those which give a provide of web administrations to your web application. All the environment variables are announced in the .env document which incorporates the parameters required for introducing the configuration.

By default, the .env document incorporates following parameters −

APP_ENV = local 

APP_DEBUG = genuine 

APP_KEY = base64:ZPt2wmKE/X4eEhrzJU6XX4R93rCwYG8E2f8QUA7kGK8 = 

APP_URL = http://localhost 

DB_CONNECTION = mysql 

DB_HOST = 127.0.0.1 

DB_PORT = 3306 

DB_DATABASE = property 

DB_USERNAME = property 

DB_PASSWORD = mystery 

CACHE_DRIVER = record 

SESSION_DRIVER = record 

QUEUE_DRIVER = adjust 

REDIS_HOST = 127.0.0.1 

REDIS_PASSWORD = invalid 

REDIS_PORT = 6379 

MAIL_DRIVER = smtp 

MAIL_HOST = mailtrap.ioMAIL_PORT = 2525 

MAIL_USERNAME = invalid 

MAIL_PASSWORD = invalid 

MAIL_ENCRYPTION = invalid 

Important Points

While function ing with fundamental configuration documents of Laravel, the accompanying focuses are to be noted −

  • The .env document ought not be focused on the application source control, since every engineer or client has some predefined environment configuration for the web application.

  • For backup alternatives, the improvement group ought to incorporate the .env.example record, which ought to contain the default configuration.

    Retrieval of Environment Variables

    All nature factors announced in the .env document can be gotten to by env-helper functions which will call the separate parameter. These factors are additionally recorded into $_ENV worldwide variable at whatever point application gets a demand from the client end. You can get to nature variable as appeared beneath −

    'env' => env('APP_ENV', 'creation'), 
    
    

    env-helper functions are called in the app.php record incorporated into the config envelope. The above given model is requiring the essential local parameter.

    Accessing Configuration Values

    You can without much of a stretch access the configuration values anyplace in the application utilizing the worldwide config partner function . On the off chance that if the configuration values are not introduced, default values are returned.

    For model, to set the default time zone, the accompanying code is utilized −

    config(['app.timezone' => 'Asia/Kolkata']); 
    
    

    Caching of Configuration

    To increment the execution and to help the web application, it is imperative to cache all the configuration values . The order for reserving the setup values is −

    config:cache 
    
    

    The following screen capture indicates storing in an efficient methodology −

    Configuration Caching

    Maintenance Mode

    Sometimes you may need to refresh some setup values or perform upkeep on your site. In such cases, keeping it in support mode, makes it less demanding for you. Such web applications which are kept in support mode, throw a special case to be specific MaintenanceModeException with a status code of 503.

    You can empower the upkeep mode on your Laravel web application utilizing the accompanying direction −

    php artisan  down 
    
    

    PHP Artisian Down