Utilities for Symfony Rest Services
Injecting the Router expression Language you can use the the custom Expression Language class in the routing conditions, this class contains the PHP version_compare function for versioning rest web services
/**
* @Get("notes", condition="compare(request.attributes.get('version'),'1', '<')")
*/
public function cgetAction()
{
return $this->getRepository()->findAll();
}
/**
* @Get("notes", condition="compare(request.attributes.get('version'),'1', '>=')")
*/
public function cgetNewVersionAction()
{
echo 'new version';
return $this->getRepository()->findAll();
}
Add the following lines in your composer.json
file:
{
"require": {
"manticora/rest-extra-bundle": "0.1"
}
}
Now, run composer.phar to download the bundle:
$ php composer.phar install
Note: You can immediately start using it. The autoloading files have been generated by composer and already included to the app autoload file.
Finally, enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Manticora\RestExtraBundle\ManticoraRestExtraBundle(),
);
}
- Json Patch
- Url Matcher rewrite
- AbstractHalRepository
- Hal Test Utility
- JMS Serializer Group Strategy rewrite
- Paginated Representation rewrite
RestExtraBundle is released under the MIT License. See the bundled LICENSE file for details.