How to set and get config variable in Laravel 5 – onlinecode

How to set and get config variable in Laravel 5 – onlinecode

In this post we will give you information about How to set and get config variable in Laravel 5 – onlinecode. Hear we will give you detail about How to set and get config variable in Laravel 5 – onlinecodeAnd how to use it also give you demo for it if it is necessary.

You can easily get your configuration values using the config helper function from anywhere in your running application.

You can define your credentials which you can access from anywhere by using global config helper function.

You can set config value at runtime if value does not exist and most of the people are using .env file to set some credentials as details of database.

To get config value

  1. $value=config('app.timezone');
$value = config('app.timezone');

You can also define your custom config variable as record per page for pagination in view.php

To Set config value

You can change your timezone at runtime too.

  1. config(['app.timezone'=>'YOUR TIME ZONE']);
config(['app.timezone' => 'YOUR TIME ZONE']);
I generally set some global variable this will be very helpfull when you are using api of mandrill, mailgun and many more and you need to set credentials for that then you can set it in services.php.

Hope this code and post will helped you for implement How to set and get config variable in Laravel 5 – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

8  +  2  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US