PHP code example of motia / laravel-jms-serializer
1. Go to this page and download the library: Download motia/laravel-jms-serializer 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/ */
motia / laravel-jms-serializer example snippets
// MyController.php
...
public function hello(\Motia\LaravelJMSSerializer\Contracts\ResponseSerializer $serializer) {
...
return $serializer->success($object);
}
// return a successful response with status 200
$serializer->success($data = null, $code= 200, $context = null);
// return a failure response, for example validation
$serializer->fail($data = null, $code = 422, $context = null);
// return an error response, for unexpceted errors
$serializer->error($message, $data = null, $code = 500, $context = null);
// return the normalized array of the php objects; equivalent to `DataNormalizer::normalize()`
$serializer->normalize($object, $context = null);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.