Laravel Set and Get Global variables using controller
In this Post We Will Explain About is Laravel Set and Get Global variables using controller With Example and Demo.
Welcome on infinityknow.com – Examples ,The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to define Global Variable or Constant in Laravel
In this post we will show you Best way to implement laravel create global variable in controller, hear for How to How to define Global or constant Variables in Laravel 5 with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
How to set and get config variable in Laravel
PHP Part Laravel framework is awesome framework in simple todays. PHP Part Laravel provide sevaral Best feature and simple why it is very popular framework in PHP.Defining Global Variables in Laravel generally if we are work on big Project or website project or simple ERP level project we always need to define some global define Varibles(in config/global.php file) like site title, number of getLivePage, footer text etc as depend on our Live project. So, I am going to show we how to define and use global define Varibles(in config/global.php file) in PHP Part Laravel 5. PHP Part Laravel 5 provide very simple way to set simple Global Variables in our Live laravel application. It is very pretty simple and with Best Folder structure.
First we have to simple create global.php file in this config folder of your simple laravel 5 application. I did add simple three define Varibles(in config/global.php file) in that file : headerTitle, getLivePage and getFooter. we can also add more then one on that file. In this learn to example we can access that define Varibles(in config/global.php file) in all application, i mean we can get simple global define Varibles(in config/global.php file) value on controller module, view side, model and all the places. so copy bellow source code and data put in global.php file.
config/global.php
[php]
return [
‘headerTitle’ => ‘infinityknow.com’,
‘getLivePage’ => 15,
‘getFooter’ => ‘Wel-come to infinityknow.com’
];
[/php]
After creating this file we can use simple using config() helper. in bellow line we can data put all the places and get “headerTitle” value, same way we can get other value too.
Example:
[php]
{{ config(‘global.headerTitle’) }}
[/php]
I hope you have Got How to define Global or constant Variables in Laravel 5 And how it works.I would Like to have FeadBack From My Blog(infinityknow.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.