Case (L5.4)
Currently trying to write an api wrapper using the package development Laravel offers.
I got a ServiceProvider
which binds the model (Niki::class
)
class NikiServiceProvider extends ServiceProvider { /** * Bootstrap the application services. * * @return void */ public function boot() { $this->publishes([ __DIR__ . '/config/niki.php' => config_path('niki.php'), ]); } /** * Register the application services. * * @return void */ public function register() { $this->app->bind('niki', function () { return new Niki; }); } }
A Facade
which registers the name of the component
class Facade extends IlluminateSupportFacadesFacade { /** * Get the registered name of the component. * * @return string */ public static function getFacadeAccessor() { return 'niki'; } }
And a model
class Niki extends Model { /** * Config * * @var array */ public function __construct() { $this->config = config('niki')['api_key']; } public static function getHouses() { $response = $this->config; return $response; } }
Above files are located in packages/prsc/niki/src
and are being loaded using the psr-4 autoloading:
"psr-4": { "App\": "app/", "PRSC\Niki\": "packages/prsc/niki/src/" },
Error
So now my problem, the bind in the ServiceProvider returns a FatalError because of the file not being found.
FatalThrowableError in NikiServiceProvider.php line 37: Class 'PRSCNiki' not found
</div