global variable for all controller and views in Laravel

Today, We want to share with you global variable for all controller and views in Laravel.In this post we will show you set global dynamic variables in Laravel 5.8, hear for Laravel define global constants Config php file we will give you demo and example for implement.In this post, we will learn about How to set a variable inside Laravel’s blade template with an example.

Read Also:  Laravel 6 Get All query string parameters

global variable for all controller and views in Laravel

There are the Following The simple About global variable for all controller and views in Laravel Full Information With Example and source code.

As I will cover this Post with live Working example to develop How to define Global Variables in Laravel 5.8?, so the Laravel 5.8 – global and dynamic variable for this example is following below.

Read Also:  Laravel Upload Import CSV Data Into MySQL Database

How to create global variable in laravel 5.6?


set simple your array here.

return [
  'website_title' => 'pakainfo Blog',
  'pagination' => 10,
  'tagLine' => 'Welcome to pakainfo website Love You',
  'API_KEY' => 'hjh566s5df$#FDsf45f4df7ds8ds',

Use in your laravel blade view file.

{{ config('global.website_title') }}

{{ config('global.tagLine') }}

Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

Read Also:  delete image from folder in php and MySQL Database

I hope you get an idea about global variable for all controller and views in Laravel.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel 5/6/7 Angular JS CRUD Example With File Upload
  2. Read Also:  jQuery Ajax GET & POST REQUEST Methods PHP MySQLi
  3. Read Also:  Clear All Cache From Laravel project 5.7
  4. Read Also:  Publishing Ionic app to Google Play Store App Release
  5. Read Also:  Create RESTful API using PHP
  6. Read Also:  Laravel MySQL Get Last Inserted ID
  7. Read Also:  AngularJS push item to 0 index or first of $scope object
  8. Read Also:  Vuejs color picker Plugins With Examples
  9. Read Also:  $watch() Function using Angular Example
  10. Read Also:  laravel Add cascade on delete (ON DELETE CASCADE)