Download the PHP package axis/axis-curly-routing-plugin without Composer
On this page you can find all versions of the php package axis/axis-curly-routing-plugin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download axis/axis-curly-routing-plugin
More information about axis/axis-curly-routing-plugin
Files in axis/axis-curly-routing-plugin
Package axis-curly-routing-plugin
Short Description This plugin introduces to symfony 1.x a new route class that uses curly braces in pattern just like Symfony2 routes
License MIT
Homepage https://github.com/e1himself/axis-curly-routing-plugin
Informations about the package axis-curly-routing-plugin
AxisCurlyRouting
This plugin introduces to symfony 1.x a new route class that uses curly braces in pattern just like Symfony2 routes.
Installation
Use Composer. Just add this dependency to your composer.json
:
Usage
Now you can use Curly routes. Just declare routes in your routing.yml
files with
CurlyRoute
class specified:
That's all. You can reference this route as you usually do with any symfony route.
For generating URLs:
For routing requests to controller:
Sugar
Yeah. There is some new cool things you can do with this routes.
Hierarchical URLs
One of the main reasons of implementing this routes was the ability to use path variables in routes. For example you want to use something like hierarchical structure in your urls:
You could do this with default symfony routing:
This works well routing requests from /my/assets/path/image.png
to defined controller.
But when you need to generate url for that path you'll get this: /my%2Fassets%2Fpath/image.png
.
Curly routes enable you to use them for this kind of tasks.
Variables delimited by any symbols
Propel Object route on steroids
You can handle propel object requests using CurlyObjectRoute
just like you did it with sfPropelRoute
.
And you can use this like you did with sfPropelRoute
. For generating URLs:
and for retrieving object from controller:
Namespaces
Sometimes you need to use object properties plus some other variables in your URLs.
Now you can use CurlyObjectRoute
to handle this just defining namespace:
And usage. For generating URLs:
and for retrieving object from controller:
Multiple objects per route
Also you can use more than one object in your routes.
And usage. For generating URLs:
and for retrieving object from controller:
Note:
To use CurlyObjectRoute
you should upgrade your project to use
Propel 1.6 by installing PropelORMPlugin.
Extending Curly Routes
You can use any custom parameters converters with CurlyRoute
s.
Define them using transform
option:
To implement custom parameter transformer in your project create a class that implements
\Axis\S1\CurlyRouting\Transformer\DataTransformerInterface
.
This transformer takes an array of parameters on input and returns a resulting array of parameters to be used by route.
The result of transformForUrl
method will be used when you generate an URL:
On the other hand by navigating to that url (/say/foohellobar
) the route will fetch weird_word
variable with the value set to foohellobar
. Than it will be passed through all your
route's defined data transformers and you'll get the transformed variables in your request and controller:
You can do a lot of cool stuff using custom transformers without the need to implement custom routes.
By the way, CurlyObjectRoute
uses transformers to handle object requests. Look at that class to
find more about params transformers. You can chain them and reuse already implemented code.
Sounds fantastic isn't it?