timacdonald / json-api

A lightweight API resource for Laravel that helps you adhere to the JSON:API standard. Supports sparse fieldsets, compound documents, and more.
585 stars 40 forks source link

Lumen support? #36

Closed Sephen closed 1 year ago

Sephen commented 1 year ago

Does this library work with Laravel/lumen?

I'm getting all kinds of errors like: Declaration of App\Http\Resources\TestResource::toAttributes($request) must be compatible with TiMacDonald\JsonApi\JsonApiResource::toAttributes(Illuminate\Http\Request $request): array in ...

Adding use Illuminate\Http\Request and public function toAttributes(Request $request): array Results in: Target [Illuminate\Contracts\Routing\ResponseFactory] is not instantiable.

Sephen commented 1 year ago

Solved bij adding:

$this->app->singleton(\Illuminate\Contracts\Routing\ResponseFactory::class, function() {
    return new \Laravel\Lumen\Http\ResponseFactory();
});

in AppServiceProvider.php