Aliases module for Kohana Framework
This module allows you to make usefull and beautifull URLs for your service.
You don't need more /user/<id>
or /article/<id>
cursors in routes. Now you can use simply /donald
and /victory
or /pokemon-go
like addresses for different resources.
User Guide
Article describing this HMVC feature placed on our website https://ifmo.su/alias-system
To include module, just place it to the /modules
directory and push to the Kohana::modules()
array in bootstrap.php
Kohana::modules(array(
'aliases' => MODPATH . 'aliases', // Aliases for URLs
...
));
All you need after is to incule alias creation and updating at your logic:
Creating
$alias = Model_Alias::generateUri( $uri );
$resource_type = Model_Uri::ARTICLE; // your own resource's type such as user, article, category and other
$resource_id = 12345;
$article->uri = Model_Alias::addAlias($alias, $resource_type , $resource_id);
Updating
$resource_id = $article->id;
$old_uri = $article->uri;
$new_uri = Model_Alias::generateUri( $uri );
$resource_type = Model_Uri::ARTICLE;
$article->uri = Model_Alias::updateAlias($old_uri, $new_uri, Model_Uri::ARTICLE, $resource_id);
What about cache
Note that module's version does not includes a cache scheme. You may need memcache
or another driver to add this feature.
Repository
https://github.com/codex-team/kohana-aliases/
About CodeX
We are small team of Web-developing fans consisting of IFMO students and graduates located in St. Petersburg, Russia. Fell free to give us a feedback on team@ifmo.su