PHPackages                             codex-team/kohana-aliases - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. codex-team/kohana-aliases

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

codex-team/kohana-aliases
=========================

This module allows you to make usefull and beautifull URLs for your service.

862[1 issues](https://github.com/codex-team/kohana-aliases/issues)PHP

Since Apr 17Pushed 8y ago2 watchersCompare

[ Source](https://github.com/codex-team/kohana-aliases)[ Packagist](https://packagist.org/packages/codex-team/kohana-aliases)[ RSS](/packages/codex-team-kohana-aliases/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Aliases module for Kohana Framework
===================================

[](#aliases-module-for-kohana-framework)

This module allows you to make useful and beautiful URLs for your service.

You don't need more `/user/` or `/article/` cursors in routes. Now you can use simply `/donald` and `/victory` or `/pokemon-go` like addresses for different resources.

User Guide
----------

[](#user-guide)

Article describing this HMVC feature placed on our website .

### Installing

[](#installing)

Firstly 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.

```
git submodule add https://github.com/codex-team/kohana-aliases modules/aliases
```

To enable module push it to `Kohana::modules()` array in `bootstrap.php`

```
Kohana::modules(array(
    'aliases' => MODPATH . 'aliases', // Aliases for URLs
    ...
));
```

### Defining project's entities

[](#defining-projects-entities)

In `classes` directory create a subdirectory `Aliases` with file `Controller.php`. You can copy [classes/Kohana/Aliases/Controller.php](classes/Kohana/Aliases/Controller.php).

Create constants for your site's entities and add them to Controllers map.

```
const ARTICLE   = 1;
const USER      = 2;
...

const MAP = array(
    self::ARTICLE   => 'Articles',
    self::USER      => 'Users',
    ...
);
```

It means that entity `ARTICLE` will be handled by controller with name `Articles`.

#### Subcontrollers

[](#subcontrollers)

Aliases module suggest you two types of subcontrollers:

- `Index` for showing entities
- `Modify` for do anything else with them

##### Example

[](#example)

If you have entity `User`, then create two controllers

1. To show user by uri `/alice` or `/bob`:

`Controller/Users/Index.php` with action `action_show`

2. To do any editions as adding, deleting. Uri: `/my-great-article/edit` or `/not-a-good-user/ban`

`Controller/Users/Modify.php` with all other actions e.g. `action_edit`, `action_ban`, `action_delete`.

All you need after is to include aliases creation and updating methods into your logic.

### Set system routes

[](#set-system-routes)

If 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.

### Database

[](#database)

Migrations for Aliases table in MySQL database migrations are in the [migrations/Aliases.sql](migrations/Aliases.sql) file.

### Create a new alias

[](#create-a-new-alias)

```
$alias         = Model_Aliases::generateUri($uri);
$resource_type = Aliases_Controller::ARTICLE;       // your own resource's type such as user, article, category and other
$resource_id   = 12345;

$article->uri = Model_Aliases::addAlias($alias, $resource_type, $resource_id);
```

### Update alias

[](#update-alias)

```
$resource_id   = $article->id;
$old_uri       = $article->uri;
$new_uri       = Model_Aliases::generateUri($uri);
$resource_type = Aliases_Controller::ARTICLE;

$article->uri = Model_Aliases::updateAlias($old_uri, $new_uri, $resource_type, $resource_id);
```

### Remove alias

[](#remove-alias)

```
$hash = Model_Aliases::createRawHash($route);

Model_Aliases::deleteAlias($hash);
```

Database and cache
------------------

[](#database-and-cache)

You can create a `Model_DB_Aliases` class and create your own function to work with database e.g. for use caching system.

Copy file [classes/Model/DB/Aliases.php](classes/Model/DB/Aliases.php) and rewrite functions.

Repository
----------

[](#repository)

[](https://github.com/codex-team/kohana-aliases/)

About CodeX
-----------

[](#about-codex)

We are small team of Web-developing fans consisting of IFMO students and graduates located in St. Petersburg, Russia. Feel free to give us a feedback on [](mailto::team@ifmo.su)

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 51.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16060815?v=4)[CodeX](/maintainers/codex-team)[@codex-team](https://github.com/codex-team)

---

Top Contributors

[![talyguryn](https://avatars.githubusercontent.com/u/15259299?v=4)](https://github.com/talyguryn "talyguryn (15 commits)")[![neSpecc](https://avatars.githubusercontent.com/u/3684889?v=4)](https://github.com/neSpecc "neSpecc (7 commits)")[![khaydarov](https://avatars.githubusercontent.com/u/6507765?v=4)](https://github.com/khaydarov "khaydarov (6 commits)")[![n0str](https://avatars.githubusercontent.com/u/988885?v=4)](https://github.com/n0str "n0str (1 commits)")

---

Tags

aliasesbeautiful-urlskohanakohana-php-framework

### Embed Badge

![Health badge](/badges/codex-team-kohana-aliases/health.svg)

```
[![Health](https://phpackages.com/badges/codex-team-kohana-aliases/health.svg)](https://phpackages.com/packages/codex-team-kohana-aliases)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
