Failed to register a package created in Laravel 5.1

Asked

Viewed 106 times

1

I am developing a package for Laravel 5.1 and I have identified a problem that I could not find the solution.

Displays the following error:

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

However, it doesn’t work at all, me code.

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 not rolled, presents the error quoted at the beginning of the post.

1 answer

4


Vendor -> Intocavel

Most likely you forgot to tell the Commodore to reindexe the namespaces:

composer dump-autoload
  • Blz, concerning the composer dump-autoload it was executed, however, the error persisted. I modified the structure - I took it from the vendor - and everything flowed accordingly. Thank you!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.