Closed scryba closed 6 years ago
Hi,
you should use the PSR-Bridge to have the support of PSR7 requests Laravel: https://laravel.com/docs/5.6/requests#psr7-requests
After integration you can just type hint the request in your action:
public function show(ServerRequestInterface $request)
With the PSR7 request already available it should be easy to create the jsonapi object:
$jsonApi = new JsonApi(new \WoohooLabs\Yin\JsonApi\Request\Request($request, $exceptionFactory), new \Zend\Diactoros\Response(), $exceptionFactory);
The id should be available through the routing:
Route::get('example/{id}', 'ExampleController@show')->name('example.show');
public function show(ServerRequestInterface $request, $id)
Your problems here are not related to woohoolabs/yin. They are related to laravel. I think you should ask those question in the laravel community or on stackoverflow.
Thanks @gfemorris very very helpful.
@gfemorris Thank you very much for the detailed answer :) I am not familiar with Laravel at all so it was really helpful for me too!
I'll close this now. I hope that all your problems have been solved in connection with this issue.
Hello I have finally integrated Yin into laravel 5.6 with dingo API But stuck here.
Below is my code.
$id = $jsonApi->getRequest()->getAttribute("id");
returns nullmy url is of the form
http://api.example.com/countries/281615
Are mine implementing this the right way or do i have to use laravel/Dingo Request class
Dingo\Api\Http\Request
my route
Works fine if manually set the id for instance on my user class
using the request url
http://api.example.com/users/11122?include=country&limit=1
I get the response
Thanks just need some guidance to complete this.