{"id":18888025,"url":"https://github.com/codex-team/kohana-aliases","last_synced_at":"2025-04-14T23:08:49.466Z","repository":{"id":56955836,"uuid":"63326131","full_name":"codex-team/kohana-aliases","owner":"codex-team","description":"Module which allows you to create beautiful URL's","archived":false,"fork":false,"pushed_at":"2018-04-17T15:20:37.000Z","size":39,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T23:08:45.493Z","etag":null,"topics":["aliases","beautiful-urls","kohana","kohana-php-framework"],"latest_commit_sha":null,"homepage":"https://ifmo.su/alias-system","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codex-team.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-14T10:16:36.000Z","updated_at":"2023-08-04T01:23:04.000Z","dependencies_parsed_at":"2022-08-21T08:20:41.278Z","dependency_job_id":null,"html_url":"https://github.com/codex-team/kohana-aliases","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fkohana-aliases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fkohana-aliases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fkohana-aliases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codex-team%2Fkohana-aliases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codex-team","download_url":"https://codeload.github.com/codex-team/kohana-aliases/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975316,"owners_count":21192209,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aliases","beautiful-urls","kohana","kohana-php-framework"],"created_at":"2024-11-08T07:41:29.904Z","updated_at":"2025-04-14T23:08:49.449Z","avatar_url":"https://github.com/codex-team.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Aliases module for Kohana Framework\n\nThis module allows you to make useful and beautiful URLs for your service.\n\nYou don't need more `/user/\u003cid\u003e` or `/article/\u003cid\u003e` cursors in routes. Now you can use simply `/donald` and `/victory` or `/pokemon-go` like addresses for different resources.\n\n## User Guide\n\nArticle describing this HMVC feature placed on our website [https://ifmo.su/alias-system](https://ifmo.su/alias-system).\n\n### Installing\n\nFirstly you need to copy this module to your project. You can download this repository and place its files to the `/modules` directory or attach it as a submodule. \n\n```shell\ngit submodule add https://github.com/codex-team/kohana-aliases modules/aliases\n```\n\nTo enable module push it to `Kohana::modules()` array in `bootstrap.php`\n\n```php\nKohana::modules(array(\n    'aliases' =\u003e MODPATH . 'aliases', // Aliases for URLs\n    ...\n));\n```\n\n### Defining project's entities\n\nIn `classes` directory create a subdirectory `Aliases` with file `Controller.php`. You can copy [classes/Kohana/Aliases/Controller.php](classes/Kohana/Aliases/Controller.php).\n\nCreate constants for your site's entities and add them to Controllers map.\n\n```php\nconst ARTICLE   = 1;\nconst USER      = 2;\n...\n\nconst MAP = array(\n    self::ARTICLE   =\u003e 'Articles',\n    self::USER      =\u003e 'Users',\n    ...\n);\n```\n\nIt means that entity `ARTICLE` will be handled by controller with name `Articles`.\n\n#### Subcontrollers\n\nAliases module suggest you two types of subcontrollers:\n\n- `Index` for showing entities\n- `Modify` for do anything else with them\n\n##### Example\n\nIf you have entity `User`, then create two controllers\n\n1. To show user by uri `/alice` or `/bob`:\n\n`Controller/Users/Index.php` with action `action_show`\n\n2. To do any editions as adding, deleting. Uri: `/my-great-article/edit` or `/not-a-good-user/ban`\n\n`Controller/Users/Modify.php` with all other actions e.g. `action_edit`, `action_ban`, `action_delete`.\n\nAll you need after is to include aliases creation and updating methods into your logic.\n\n### Set system routes\n\nIf you want to set up system routes for your site or block some which shouldn't be allowed to use as alias. Then use [config/system-aliases.php](config/system-aliases.php) file. Lock any count of system URIs by adding them to the array.\n\n### Database\n\nMigrations for Aliases table in MySQL database migrations are in the [migrations/Aliases.sql](migrations/Aliases.sql) file.\n\n### Create a new alias\n\n```php\n$alias         = Model_Aliases::generateUri($uri);\n$resource_type = Aliases_Controller::ARTICLE;       // your own resource's type such as user, article, category and other\n$resource_id   = 12345;\n\n$article-\u003euri = Model_Aliases::addAlias($alias, $resource_type, $resource_id);\n```\n\n### Update alias\n\n```php\n$resource_id   = $article-\u003eid;\n$old_uri       = $article-\u003euri;\n$new_uri       = Model_Aliases::generateUri($uri);\n$resource_type = Aliases_Controller::ARTICLE;\n\n$article-\u003euri = Model_Aliases::updateAlias($old_uri, $new_uri, $resource_type, $resource_id);\n```\n\n### Remove alias\n\n```php\n$hash = Model_Aliases::createRawHash($route);\n\nModel_Aliases::deleteAlias($hash);\n```\n\n## Database and cache\n\nYou can create a `Model_DB_Aliases` class and create your own function to work with database e.g. for use caching system.\n\nCopy file [classes/Model/DB/Aliases.php](classes/Model/DB/Aliases.php) and rewrite functions.\n\n## Repository\n\n\u003ca href=\"https://github.com/codex-team/kohana-aliases/\"\u003ehttps://github.com/codex-team/kohana-aliases/\u003c/a\u003e\n\n## About CodeX\n\nWe are small team of Web-developing fans consisting of IFMO students and graduates located in St. Petersburg, Russia.\nFeel free to give us a feedback on \u003ca href=\"mailto::team@ifmo.su\"\u003eteam@ifmo.su\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-team%2Fkohana-aliases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodex-team%2Fkohana-aliases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodex-team%2Fkohana-aliases/lists"}