2017 © Pedro Peláez
 

library doctrine-json-api

A package for handling JSON API requests with Doctrine

image

giadc/doctrine-json-api

A package for handling JSON API requests with Doctrine

  • Thursday, August 10, 2017
  • by giadc-dev
  • Repository
  • 2 Watchers
  • 1 Stars
  • 90 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 8 % Grown

The README.md

JSON API Request

A package for automating pagination, filtering, sorting, and includes when working with Doctrine and the JSON API standard., (*1)

Installation

composer install giadc/doctrine-json-api, (*2)

Basic Usage

Using the Read Service

$entityReadService->findById('id123', $includes = []);
$entityReadService->findByArray(['id123', 'id456'], 'id', $includes = []);
$entityReadService->findByField('name', 'Chiquita');
$entityReadService->paginate($includes = []);
<?php
namespace App\Bananas\Services;

use App\Common\Services\AbstractReadService;
use App\Bananas\Repositories\BananaRepositoryInterface as BananaRepo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class RoleReadService extends AbstractReadService
{
    public function __construct(
        BananaRepo $bananaRepo
    ) {
        $this->initialize($bananaRepo, 'Banana');
    }

Filters Skeleton

<?php

namespace App\Bananas\Filters;

use Giadc\DoctrineJsonApi\Filters\FilterManager;

/**
 * Class BananaFilters
 */
class BananaFilter extends FilterManager
{
    /**
     * @var array
     */
    protected $accepted = [
        'id'    => ['type' => 'id'],      // id must match exactly
        'name' => ['type' => 'keyword'], // keyword will match fuzzily
    ];
}

Repository Skeleton

<?php
namespace App\Bananas\Repositories;

use App\Bananas\Banana;
use App\Bananas\Filters\BananaFilter;
use App\Bananas\Repositories\BananaRepositoryInterface;
use Doctrine\ORM\EntityManagerInterface as EntityManager;
use Giadc\DoctrineJsonApi\Interfaces\AbstractJsonApiRepositoryInterface as JsonApiInterface;
use Giadc\DoctrineJsonApi\Repositories\AbstractJsonApiDoctrineRepository as JsonApiRepository;

class RoleDoctrineRepository extends JsonApiRepository implements
JsonApiInterface,
RoleRepositoryInterface
{
    /** @var EntityManager */
    protected $em;

    /** @var string */
    protected $class;

    /** @var BananaFilter **/
    protected $filters;

    /**
     * Create a new BananaDoctrineRepository
     *
     * @param EntityManager $em
     * @param BananaFilters $filters
     * @return void
     */
    public function __construct(EntityManager $em, BananaFilter $filters)
    {
        $this->em      = $em;
        $this->class   = Role::class;
        $this->filters = $filters;
    }
}

The Versions

10/08 2017

dev-master

9999999-dev

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti

10/08 2017

1.1.0

1.1.0.0

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti

17/05 2017

1.0.2

1.0.2.0

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti

02/05 2017

1.0.1

1.0.1.0

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti

29/12 2016

1.0.x-dev

1.0.9999999.9999999-dev

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti

29/12 2016

1.0.0

1.0.0.0

A package for handling JSON API requests with Doctrine

  Sources   Download

MIT

The Requires

 

The Development Requires

by David Hill
by Ryan Marganti