title: Creating a Global Variable in the AppServiceProvider Laravel 5.3
body: <p>Hi I have posted this on Laracasts but so far no answers so thought I'd try here :)</p>
  
  <p>I'm trying to get a couple of global variables to views using the AppServiceProvider. I've not had a problem if I use one of Laravel's facades to get user details for example but with dependency injection I've not been able to work it out.</p>
  
  <p>This is the code I currently have:</p>
  
  <pre><code>&lt;?php namespace App\Providers;
  
  use Illuminate\Support\ServiceProvider;
  
  use App\Repositories\ShopCategory\ShopCategoryInterface;
  
  class AppServiceProvider extends ServiceProvider
  {
      /**
       * Bootstrap any application services.
       *
       * @return void
       */
      public function boot(ShopCategoryInterface $shop_category)
      {
          $parent_categories = $shop_category-&gt;getParentCategories();
  
          view()-&gt;composer('*', function($view){
              $view-&gt;with('parent_categories', $shop_category-&gt;getParentCategories());
      });
  }
  
      /**
       * Register any application services.
       *
       * @return void
      */
      public function register()
      {
  
      }
  }
  </code></pre>
  
  <p>I had assumed this would work but I get the error: </p>
  
  <pre><code>Undefined variable: shop_category
  </code></pre>
  
  <p>So i'm just wondering how I pass the $shop_category class to the view composer.</p>
  
  <p>Thanks for any help</p>