Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/polidog/simpleapibundle


https://github.com/polidog/simpleapibundle

library php-library symfony-bundle

Last synced: 7 days ago
JSON representation

Awesome Lists containing this project

README

        

# PolidogSimpleApiBundle

## Installation

```
$ composer require polidog/simple-api-bundle "dev-master"
```

Add config/bundles.php

```php
['all' => true]
];

```

## Introduce bundle configuration to your config file

```yaml
# config/packages/polidog_simple_api.yml

polidog_simple_api: ~
```

## Usage

```php
userRepository->find($id);
return [
'id' => $user->getId(),
'name' => $user->getUsername(),
'avatar' => $user->getAvatar(),
];
}

/**
* for php7
* @Route("/user/post", methods={"POST"})
* @Api(statusCode=201)
*/
#[Route('/user/post', name: 'POST')]
#[Api(201)]
public function post(Request $request): array
{
// TODO save logic.
return [
'status' => 'ok',
];
}
}

```