Failed to register a package created in Laravel 5.1

1

I'm developing a package for Laravel 5.1 and I've already identified a problem that I could not find the solution for.

Displays the following error:

FatalErrorException in ProviderRepository.php line 146:
Class 'MyNamespace\MyApp\MyAppServiceProvider' not found

However, it does not work at all, just code me.

composer.json

...
"psr-4": {
    "MyNamespace\MyApp\": "vendor/mynamespace/myapp/src/"
}
...

vendor / mynamespace / myapp / src / MyAppServiceProvider.php

<?php

namespace MyNamespace\MyApp;

use Illuminate\Support\ServiceProvider;

class MyAppServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap the application services.
     *
     * @return void
     */
    public function boot()
    {
        require __DIR__ . '/../vendor/autoload.php';

        if (! $this->app->routesAreCached()) {
            require __DIR__.'/../../routes.php';
        }
    }

    /**
     * Register the application services.
     *
     * @return void
     */
     public function register()
     {
         //
     }
}

And finally, I try to register my ServiceProvider, but ...

config / app.php

'providers' => [
    ...
    MyNamespace\MyApp\MyAppServiceProvider::class

],

But it did not roll, it displays the error quoted at the beginning of the post.

    
asked by anonymous 23.06.2015 / 19:53

1 answer

4

Vendor - > Intocavel

Very likely you forgot to tell the composer to reindex the namespaces:

composer dump-autoload
    
23.06.2015 / 20:16