Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/boshurik/apibundle
https://github.com/boshurik/apibundle
Last synced: 4 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/boshurik/apibundle
- Owner: BoShurik
- License: mit
- Created: 2020-10-21T16:39:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T14:04:22.000Z (almost 4 years ago)
- Last Synced: 2024-11-21T13:29:39.529Z (2 months ago)
- Language: PHP
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ApiBundle
[![Build Status](https://travis-ci.com/BoShurik/ApiBundle.svg?branch=master)](https://travis-ci.com/BoShurik/ApiBundle)
Set of useful services for building API
## Installation
#### Composer
``` bash
$ composer require boshurik/api-bundle
```If you are using [symfony/flex][1] it is all you need to do
#### Register the bundle
``` php
['all' => true],
];```
## Usage
#### ArgumentResolver
```php
class SomeController
{
public function someAction(SomeModel $model)
{
// $model - validated object
}
}
```#### Serializer
```php
/**
* @var SomeEntity $entity
*/
$data = $this->serializer->normalize($entity); // $entity->getId() value
$entity = $this->serializer->denormalize('some-id', SomeEntity::class); // SomeEntity instant
```#### ValidationException
```php
$violations = $this->validator->validate($model);
if ($violations->count() > 0) {
throw new ValidationException($violations);
}
```[1]: https://flex.symfony.com