boshurik/api-bundle

Set of useful services for building API

Maintainers

👁 BoShurik

Package info

github.com/BoShurik/ApiBundle

pkg:composer/boshurik/api-bundle

Statistics

Installs: 1 370

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.3.1 2021-04-16 14:00 UTC

Requires

Suggests

Provides

None

Conflicts

None

Replaces

None

MIT d709b9ec1ff81ffb23d2be151993c5328d3421d4

  • BoShurik <boshurik.woop@gmail.com>

This package is auto-updated.

Last update: 2026-06-17 02:05:29 UTC


README

👁 Build Status

Set of useful services for building API

Installation

Composer

$ composer require boshurik/api-bundle

If you are using symfony/flex it is all you need to do

Register the bundle

<?php
// config/bundles.php

return [
 //...
 \BoShurik\ApiBundle\BoShurikApiBundle => ['all' => true],
];

Usage

ArgumentResolver

class SomeController
{
 public function someAction(SomeModel $model)
 {
 // $model - validated object 
 }
}

Serializer

/**
 * @var SomeEntity $entity
 */
$data = $this->serializer->normalize($entity); // $entity->getId() value
$entity = $this->serializer->denormalize('some-id', SomeEntity::class); // SomeEntity instant 

ValidationException

$violations = $this->validator->validate($model);
if ($violations->count() > 0) {
 throw new ValidationException($violations);
}