gimmenetwork / api-platform
Unified tooling for building API
This package's canonical repository appears to be gone and the package has been frozen as a result.
Installs: 1 861
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:bundle
Requires
- ext-json: *
- beberlei/assert: ^3.2
- doctrine/orm: ^2.6
- ircmaxell/random-lib: ^1.2
- jms/serializer-bundle: ^3.4
- monolog/monolog: ^2.0
- ramsey/uuid: ^4.1
- ramsey/uuid-doctrine: ^1.6
- symfony/console: 5.2.*
- symfony/dotenv: 5.2.*
- symfony/flex: ^1.3.1
- symfony/framework-bundle: 5.2.*
- symfony/http-client: ^5.2
- symfony/mailer: 5.2.*
- symfony/monolog-bridge: ^5.2
- symfony/orm-pack: ^1.0
- symfony/security-bundle: 5.2.*
- symfony/templating: 5.2.*
- symfony/test-pack: ^1.0
- symfony/twig-pack: ^1.0
- symfony/yaml: 5.2.*
README
- Installation
- Configuration
Installation
Pretty simple:
composer require gimmenetwork/api-platform
After the bundle is installed, enable it in config/bundles.php
<?php return [ ... Gimmemore\API\ApiPlatformBundle::class => ['all' => true] ]
Usage
Filters
Register compiler pass in Kernel
<?php // src/Kernel.php use Gimmemore\API\Filters\Filter; use Gimmemore\API\DependencyInjection\CompilerPass\RegisterFilters; ... protected function build(ContainerBuilder $container) : void { ... $container->registerForAutoconfiguration(Filter::class)->addTag(RegisterFilters::CONTAINTER_TAG); $container->addCompilerPass(new RegisterFilters()); }
Every filter implement Filter
interface:
<?php declare(strict_types=1); namespace Gimmemore\API\Filters; use Doctrine\ORM\QueryBuilder; interface Filter { public function applyTo(QueryBuilder $builder, string $alias): void; public static function getType(): string; public static function createFromValue($value): self; }
If you want to filter by status
, you have to register Filter that has type status
.
Exception handling
Register compiler pass in Kernel
<?php // src/Kernel.php use Gimmemore\API\ExceptionHandling\ExceptionResponseHandler; use Gimmemore\API\DependencyInjection\CompilerPass\RegisterResponseHandlers; ... protected function build(ContainerBuilder $container) : void { ... $container->registerForAutoconfiguration(ExceptionResponseHandler::class)->addTag(RegisterResponseHandlers::CONTAINER_TAG); $container->addCompilerPass(new RegisterResponseHandlers()); }
There can be only one handler per Exception
class.