title: Laravel Package Creation
body: <p>So I'm writing a Laravel Package that will eventually exist on git (or wherever).</p>
  
  <p>I've created the package structure as outlined here (<a href="https://rathes.de/blog/en/laravel-package" rel="nofollow noreferrer">https://rathes.de/blog/en/laravel-package</a>, great resource by the way), in /app/ and I've also created a Facade.php, PackageServiceProvoder.php and a controller that dumps "Hello world" to the browser. </p>
  
  <p>I also have a pre-existing HomeController.php and I've added the following to the test function:</p>
  
  <pre><code>dd(\MyPackage::test());// &lt;-- Should dump "Hello world" and die.
  </code></pre>
  
  <p>I've also added the following to the packages' composer.json file and run composer install:</p>
  
  <pre><code>"autoload": {
      "psr-4": {
          "Company\\LaravelPackageMyPackage\\": "src"
      }
  },
  "autoload-dev": {
      "psr-4": {
          "Company\\LaravelPackageMyPackage\\Test\\": "tests"
      }
  },
  "extra": {
      "laravel": {
          "providers": [
  "Company\\LaravelPackageMyPackage\\Lar...kageServiceProvider"
          ],
          "aliases": {
              "MyPackage": "Company\\LaravelPackageMyPackage\\Facade"
          }
      }
  },
  </code></pre>
  
  <p>The problem I have is that when I run this in the browser I get the following error:</p>
  
  <pre><code>Class 'MyPackage' not found // &lt;-- references the dd() line of code above
  </code></pre>
  
  <p>I must have missed a step during the tutorial or something like that because as far as I can see it should be working now.
  Any suggestions guys?</p>
  
  <p>Laravel 5.5, PHP 7.1, Ubuntu Linux os.</p>
  
  <p>Just code below here:</p>
  
  <pre><code>File structure (very similar to this):
  Project -&gt; app -&gt; my-package /
  
  ├── database/
  │   ├── .gitkeep
  ├── config/
  │   ├── package-name.php
  ├── src/
  │   ├── PackageNameServiceProvider.php
  ├── tests/
  │   ├── TestCase.php
  ├── .gitignore
  ├── CHANGELOG.md
  ├── composer.json
  ├── LICENSE
  ├── phpunit.xml
  ├── README.md
  
  // FACADE:
  &lt;?php
  namespace Company\LaravelPackageMyPackage;
  
  class Facade extends \Illuminate\Support\Facades\Facade
  {
      /**
       * {@inheritDoc}
       */
      protected static function getFacadeAccessor()
      {
          return 'laravelpackagemypackage';
      }
  }
  
  // MY PACKAGE
  &lt;?php
  namespace Company\LaravelPackageMyPackage;
  
  class LaravelPackageMyPackage
  {
      public function test()
      {
          return "Hello From My Package!";
      }
  }
  
  // SERVICE PROVIDER:
  &lt;?php
  namespace Company\LaravelPackageMyPackage;
  use Illuminate\Support\Facades\App;
  use Illuminate\Support\ServiceProvider;
  
  class LaravelPackageMyPackageServiceProvider extends ServiceProvider
  {
      protected $defer = false;
  
      public function boot()
      {
          //$this-&gt;loadMigrationsFrom(__DIR__ . '/../database/migrations/');
      }
  
      public function register()
      {
          App::bind('laravelpackagemypackage', function () {
              return new LaravelPackageMyPackage();
          });
      }
  }
  </code></pre>