Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eosnewmedia/json-api-server-bundle
The symfony integration for enm/json-api-server.
https://github.com/eosnewmedia/json-api-server-bundle
abstraction api api-server json json-api php php7 reusable symfony symfony-bundle
Last synced: about 2 months ago
JSON representation
The symfony integration for enm/json-api-server.
- Host: GitHub
- URL: https://github.com/eosnewmedia/json-api-server-bundle
- Owner: eosnewmedia
- License: mit
- Created: 2017-06-08T10:50:11.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-02-02T09:56:25.000Z (almost 2 years ago)
- Last Synced: 2024-08-26T15:57:29.990Z (4 months ago)
- Topics: abstraction, api, api-server, json, json-api, php, php7, reusable, symfony, symfony-bundle
- Language: PHP
- Homepage: https://eosnewmedia.github.io/JSON-API-Server-Bundle/
- Size: 131 KB
- Stars: 10
- Watchers: 6
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
JSON API Server-Bundle
======================
[![Build Status](https://travis-ci.org/eosnewmedia/JSON-API-Server-Bundle.svg?branch=master)](https://travis-ci.org/eosnewmedia/JSON-API-Server-Bundle)The symfony integration for [`enm/json-api-server`](https://eosnewmedia.github.io/JSON-API-Server/).
## Installation
composer require enm/json-api-server-bundle
*****
## Documentation
You should read the docs of [`enm/json-api-server`](https://eosnewmedia.github.io/JSON-API-Server/) first,
since this bundle only integrate its functionalities into your symfony project.1. [Configuration](#configuration)
1. [Bundles](#bundles)
1. [Config](#config)
1. [Routing](#routing)
1. [Request Handler](#request-handler)
1. [Error Handling](#error-handling)*****
*****## Configuration
### Bundles
```php
['all' => true],
// ...
];```
*****
### Config
All bundle configurations are optional.```yaml
# config/packages/(dev/|prod/|test/|)enm_json_api.yaml
enm_json_api_server:
debug: false
url_prefix: '' # configure this to use a url prefix for your json api routes: e.g. /api/{type}. only needed if a prefix is defined in your routing
route_name_prefix: 'enm.json_api' # Prefix of the route names in symfony (for exception handling). only needed if a nam prefix is defined in your routing
```*****
### Routing
```yaml
# app/config/routing.yml | config/routes.yaml
json_api:
resource: "@EnmJsonApiServerBundle/Resources/config/routing.xml"
```If you use the predefined routing (without api prefix configuration), the following routes will be matched:
GET /{type}
GET /{type}/{id}
GET /{type}/{id}/relationships/{relationship}
GET /{type}/{id}/{relationship}
POST /{type}
PATCH /{type}/{id}
DELETE /{type}/{id}
POST /{type}/{id}/relationships/{relationship}
PATCH /{type}/{id}/relationships/{relationship}
DELETE /{type}/{id}/relationships/{relationship}*****
## Request Handler
Each request handler can simply be registered via the service container (tag: `json_api_server.request_handler`):```yml
AppBundle\RequestHandler\YourRequestHandler:
tags:
- { name: json_api_server.request_handler, type: 'myResources' }
```The tag attribute `type` must contain the json api resource type which will be handled by this request handler.
*****
## Error Handling
The bundle will handle all exceptions and convert them to valid json api error responses.