Giter Site home page Giter Site logo

eloquentserializer's Introduction

EloquentSerializer

Package version Build Status License

Package to allow Symfony Serializer to work on Eloquent models.

Table of Contents

  1. Install
    1. Laravel
    2. Symfony
  2. Usage
  3. Contributing

Install

You can use Composer to install the bundle to your project:

composer require theofidry/eloquent-serializer

Laravel (~5.5.0)

Nothing to do, the provider is automatically discovered :)

Symfony (^3.4 || ^4.0)

Enable the bundle by updating your app/AppKernel.php file to enable the bundle:

<?php
// app/AppKernel.php

public function registerBundles()
{
    //...
    $bundles[] = new \Fidry\EloquentSerializer\Bridge\Symfony\FidryEloquentSerializerBundle();

    return $bundles;
}

Usage

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',
// ];

Contributing

You can find two bash scripts to help with the testing:

bin/setup   # Install the dependencies and setup the sqlite database
bin/tests   # Runs the tests

eloquentserializer's People

Contributors

theofidry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

eloquentserializer's Issues

Fix Travis configuration

Tests are not passing on Travis due to a silly directory issue that I can't figure out, although they are passing fine locally.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.