dyonis / symfony-api-response
Symfony API Response component
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/dyonis/symfony-api-response
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