Download the PHP package innmind/rest-bundle without Composer
On this page you can find all versions of the php package innmind/rest-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innmind/rest-bundle
More information about innmind/rest-bundle
Files in innmind/rest-bundle
Package rest-bundle
Short Description This Bundle wraps the innmind rest server library
License MIT
Homepage http://github.com/Innmind/RestBundle
Informations about the package rest-bundle
RestBundle
Wrapper for the innmind/rest-server
library allowing you to easily expose a REST L3 API.
This bundle offer a complete integration of the library in a symfony project. It also add a new feature called server capabilities; put simply, it expose a route OPTIONS *
that will output the list of routes exposed via this bundle. The goal being to allow client discovery, you could imagine a REST client that could prefetch all the resources definitions so it could know in advance if the resources it will try to send match the definitions.
Installation
Enable the bundle by adding the following line in your app/AppKernel.php
of your project:
Then specify your resources in the configuration under:
Server
Storage
To define a storage you can create a service having either innmind_rest.server.storage.abstract.doctrine
or innmind_rest.server.storage.abstract.neo4j
as parent. Then you need to specify the first argument to construct the service, being an instance of an entity manager (a doctrine or neo4j one); and flag the service with the tag innmind_rest.server.storage
, the bundle will look for the attribute alias
on this tag to use as reference afterward (name used to specify storage on your resources).
Formats
As allowed formats are handled via encoders, you declare new ones with a tag on the encoder service you want to add.
Example of the built-in json
format:
Events
In most cases the only event you'll want to alter will be KernelEvents::RESPONSE
or Events::{STORAGE}_READ_QUERY_BUILDER
(STORAGE
can be DOCTRINE
or NEO4J
) to add restriction on the query like for example the user being connected.
You can look at Events.php
to review all the events you have at your disposition.
Client
To consume an API you need to use the innmind_rest.client
service. Examples of usages:
You can use $server->getResources()
to view all the resources exposed by the server API; it will return an associative array with the names as keys and the definitions as values.
All versions of rest-bundle with dependencies
innmind/rest-server Version ~2
symfony/http-kernel Version ~2.7|~3.0
symfony/dependency-injection Version ~2.7|~3.0
symfony/config Version ~2.7|~3.0
symfony/framework-bundle Version ~2.7|~3.0
innmind/rest-client Version ~2
symfony/filesystem Version ~2.7|~3.0
innmind/url-resolver Version ^1.0
guzzlehttp/guzzle Version ~5.0
symfony/console Version ~2.7|~3.0