PHP code example of theofidry / eloquent-serializer
1. Go to this page and download the library: Download theofidry/eloquent-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/ */
theofidry / eloquent-serializer example snippets
// app/AppKernel.php
public function registerBundles()
{
//...
$bundles[] = new \Fidry\EloquentSerializer\Bridge\Symfony\FidryEloquentSerializerBundle();
return $bundles;
}
use Fidry\EloquentSerializer\Bridge\Laravel\Facade\Serializer;
// Dummy is an Eloquent model
$dummy = Dummy::create([
'id' => 100,
'name' => 'Gunner Runte',
'email' => '[email protected]',
'password' => '$2y$10$j/R4kRrymk3wMXwohvoRou2zBKJZVecr1VON.9NnSXu24k6CP6tDe',
'remember_token' => 'PhiasHkmCh',
'created_at' => new Carbon('2016-07-02T12:28:14+00:00'),
]);
// You can either use the Facade (Laravel) or the 'serializer' service (Laravel & Symfony)
$normalizedDummy = Serializer::normalize($dummy);
// $normalizedDummy: [
// 'id' => 100,
// 'name' => 'Gunner Runte',
// 'email' => '[email protected]',
// 'created_at' => '2016-07-02T12:28:14+00:00',
// ];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.