Reputation: 9201
I'm making a Laravel ServiceProvider for a package. The package is https://github.com/sumocoders/Teamleader
I get the following error
FatalErrorException in ProviderRepository.php line 150: Class 'Notflip\Teamleader\TeamleaderServiceProvider' not found
I have no clue what I'm doing wrong, Here's my folder structure
composer.json in my package
"autoload": {
"psr-4": {
"Notflip\\Teamleader": "src/"
}
}
TeamleaderServiceProvider
<?php namespace Teamleader\Laravel;
use Illuminate\Support\ServiceProvider;
class TeamleaderServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function publishes()
{
$this->publishes([
__DIR__.'/Config/config.php' => config_path('teamleader.php'),
]);
}
public function register()
{
$this->app->bind('Teamleader\Laravel', function () {
return new Teamleader(config('teamleader.API_GROUP'), config('teamleader.API_SECRET'), config('teamleader.SSL'));
});
}
}
Facade
<?php namespace Teamleader\Laravel\Facade;
class Teamleader extends Facade
{
protected static function getFacadeAccessor()
{
return 'Teamleader';
}
}
In my config.php I added the following line to the providers
'Notflip\Teamleader\TeamleaderServiceProvider',
And this line to the aliasses
'Teamleader'=> 'Notflip\Teamleader\Facade\Teamleader'
Anyone has any idea what I might be doing wrong? Thank you! I'm so close to the result!
Upvotes: 1
Views: 3920
Reputation: 9201
In the facade, the IOC binding was named wrong ( wrong case )
The name should have been 'teamleader' in lowercase.
Facade
class Teamleader extends Facade
{
protected static function getFacadeAccessor()
{
return 'teamleader';
}
}
Service Provider
<?php namespace Teamleader\Laravel;
use Illuminate\Support\ServiceProvider;
class TeamleaderServiceProvider extends ServiceProvider
{
/**
* Register bindings in the container.
*
* @return void
*/
public function publishes()
{
$this->publishes([
__DIR__.'/Config/config.php' => config_path('teamleader.php'),
]);
}
public function register()
{
$this->app->bind('teamleader', function () {
return new Teamleader(config('teamleader.API_GROUP'), config('teamleader.API_SECRET'), config('teamleader.SSL'));
});
}
}
Upvotes: 0
Reputation: 10447
Your definition in composer is missing the initial slashes and you haven't specified the path to src from root.
"psr-4": {
"\\Notflip\\Teamleader": "notflip/teamleader-laravel/src/"
}
Also your declaration of the name space at the top of TeamleaderServiceProvider is wrong, it should be:
<?php namespace Notflip\Teamleader;
Upvotes: 1