1. Go to this page and download the library: Download motrack/hoodie library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
return Hoodie::respondError('Something went wrong!', 500, $exception, $headers );
use App\Http\Resources\PostResource; // the Json Resource you've provided for the result
class PostController extends Controller
{
...
public function show(Post $post): JsonResponse
{
return Hoodie::respondWithResource(new PostResource($post) , 'Post Created Successfully', 201 , ['my_custom_header' => 'header_value']);
}
...
}
use App\Http\Resources\PostCollection; // the Json Collection you've provided for the result
class PostController extends Controller
{
public function index(): JsonResponse
{
return Hoodie::respondWithResourceCollection(new PostCollection(Post::paginate()) , 'List of Posts Retrieved Successfully', 200 , ['my_custom_header' => 'header_value']);
}
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.