dyonis / symfony-api-response
Symfony API Response component
0.1.2
2024-02-25 23:53 UTC
Requires
- php: >=7.0
- symfony/http-foundation: ^v7.0
README
Usage in controllers:
Success response
return (new ApiResponse()) ->setData(['product' => $product]) ->setMessage('Successfully saved');
Redirect response
return (new ApiResponse()) ->apiRedirect('https://some.url', 302);
Error response
$response = new ApiResponse(); $response->addErrors(['Error 1', 'Error 2']) $response->addError('Error 3'); $response->addError('Error 4', 'Field'); return $response