Download the PHP package innmind/rest-server-bundle without Composer
On this page you can find all versions of the php package innmind/rest-server-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download innmind/rest-server-bundle
More information about innmind/rest-server-bundle
Files in innmind/rest-server-bundle
Package rest-server-bundle
Short Description Symfony integration of innmind/rest-server
License MIT
Homepage http://github.com/Innmind/RestServerBundle
Informations about the package rest-server-bundle
REST Server Bundle
master |
develop |
---|---|
Installation
Via composer:
Enable the bundle by adding the following line in your app/AppKernel.php of your project:
Then you need to specify the types you allow in the app, here's an example:
Here you define you can expose your resources either in json
or html
. If the client accept any kind of content, it will automatically expose data as json
as it has the highest priority. The client can use either text/html
or application/xhtml+xml
as media type in his Accept
header in order for us to expose data as html
.
We also describe the fact resources sent to our API must me in json
only, and that the Content-Type
header sent by the client must be application/json
otherwise he will get an error.
In order to work properly, any media type here must have a corresponding serializer encoder (the supportsEnconding
must check the request_{media_type}
format, example).
Then you need to activate the router by adding this configuration:
The last part of the configuration is to create a file named rest.yml
in your bundle under the folder Resources/config
that will contain the definition of your resources. Here's an extended example:
Now that all the configuration is done, you need to create a service implementing the interface GatewayInterface
and tag the service definition with innmind_rest_server.gateway
along with an alias to your choosing; the alias is the one you'll use in the configuration of your resources as chown above (which in our case is command
).
Such a service definition should look like this:
All versions of rest-server-bundle with dependencies
innmind/rest-server Version ~5.0
symfony/http-kernel Version ~3.0
symfony/dependency-injection Version ~3.0
symfony/routing Version ~3.0
symfony/framework-bundle Version ~3.0
innmind/http Version ~3.0
innmind/immutable Version ~2.1