PHP code example of dropelikeit / laravel-responsefactory
1. Go to this page and download the library: Download dropelikeit/laravel-responsefactory 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/ */
dropelikeit / laravel-responsefactory example snippets
namespace App\Http\Controller;
use Dropelikeit\ResponseFactory\Http\Responses\ResponseFactory;
use Symfony\Component\HttpFoundation\JsonResponse;
final class ExampleController extends Controller
{
public function __construct(private ResponseFactory $responseFactory) {}
public function myAction(): JsonResponse
{
$myDataObjectWithSerializerAnnotations = new Object('some data');
return $this->responseFactory->create($myDataObjectWithSerializerAnnotations);
}
}
bash
php artisan vendor:publish