title: Laravel 5.5 : How to define global variable that can be used in all controllers ?
body: <p>Hello Developers &amp; Coders , </p>
  
  <blockquote>
    <p>My question is How to define a global variable , that can be used in
    all controllers in Laravel ?</p>
  </blockquote>
  
  <p>I have defined one variable <code>$company</code> in <strong>AppServiceProviders's boot method</strong> - that im using in all blade views , but I can not use it in controllers file , it gives error , <code>undefined variable $company</code></p>
  
  <pre><code>class AppServiceProvider extends ServiceProvider
  {
      /**
       * Bootstrap any application services.
       *
       * @return void
       */
      public function boot()
      {
          View::share('key', 'value');
          Schema::defaultStringLength(191);
  
          $company=DB::table('company')-&gt;where('id',1)-&gt;first();
          View::share('company',$company);  
  
      }
  
       /**
       * Register any application services.
       *
       * @return void
       */
      public function register()
      {
          //
      }
  
  }
  </code></pre>
  
  <p>please guide me , thanks for your efforts &amp; time :)</p>