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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lumen support?

Sephen opened this issue · comments

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.

Solved bij adding:

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

in AppServiceProvider.php