bobbybouwmann's avatar

Laravel 5 package ServiceProvider can't be found!

Hi guys,

I'm working on my first Laravle 5 package, but Laravel can't find the ServiceProvider. I'm sure I have the psr-4 stuff correct and the package is pulled in correct.

I placed the link to the service provider in my config/app.php file "blackbirddev/entry": "dev-master"

I get the error when I run php artisan vendor:publish. When I do this it should publish my config file, but instead I get this error: `PHP Fatal error: Class 'Blackbirddev\Entry\EntryServiceProvider' not found in / vagrant/public/laravel5/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 150'

Here is the code:

composer.json

"autoload": {
    "psr-4": {
        "Blackbird\\Entry\\": "src/Entry"
    }
}

EntryServiceProvider.php

<?php namespace Blackbirddev\Entry;

use Illuminate\Support\ServiceProvider;

class EntryServiceProvider extends ServiceProvider {

    /**
     * Bootstrap the application events.
     *
     * @return void
     */
    public function boot()
    {
        $this->publishes([
            __DIR__.'/../config/config.php' => config_path('entry.php'),
        ]);
    }

    /**
     * Register the service provider.
     *
     * @return void
     */
    public function register()
    {
        $this->app->bind('entrust', function ($app) {
            return new Entry($app);
        });
    }
}

If you need anything else let me know ;)

0 likes
6 replies
bobbybouwmann's avatar

Yea I did put it in the config/app.php

* blackbirddev
  * entry
    * src
      * config
        * config.php
      * Entry
        * Entry.php
        * EventServiceProvider.php
    * composer.json
bobbybouwmann's avatar
bobbybouwmann
OP
Best Answer
Level 88

Managed to fix it. It was a namespace problem

autoload": {
    "psr-4": {
        "Blackbird\\Entry\\": "src/Entry"
    }
}

Should be

autoload": {
    "psr-4": {
        "Blackbirddev\\Entry\\": "src/Entry"
    }
}
2 likes
agilasadi's avatar

I'm running into a similar problem, know it has changed quite a bit since then.

I'm trying to make my first package as well.

Here is the package URL in Packagist: https://packagist.org/packages/rapkit/wire

and this is the GitHub URL: https://github.com/rapkit/wire

I tried a few things to fix it but now I have no idea about what to do. also, I don't want to do a lot of unnecessary pushes to the repository.

Since it's working in my development environment but when I try to pull it into a new project, it starts throwing ServiceProvider not founded error.

1 like
ARNishan's avatar

@agilasadi Can you find the solution? I am also facing the same problem. My package is working fine locally but whenever I am installing the package from packagist then shows me the error "service provider class not found"

Please or to participate in this conversation.