PHPackages                             djidji/yii2-default-url-rule - 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. djidji/yii2-default-url-rule

ActiveYii2-extension

djidji/yii2-default-url-rule
============================

Parsing and creating url with arguments pretified as well instead of in query string format

v1.0.0(6y ago)033BSD-3-ClausePHP

Since Apr 30Pushed 5y ago1 watchersCompare

[ Source](https://github.com/djidji01/yii2-basic-url-rule)[ Packagist](https://packagist.org/packages/djidji/yii2-default-url-rule)[ RSS](/packages/djidji-yii2-default-url-rule/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

UrlRule for default basic logic in parsing and creating pretty Url.
===================================================================

[](#urlrule-for-default-basic--logic-in-parsing-and-creating-pretty-url)

Parsing and creating url with arguments pretified as well instead of in query string format. Route and argument segments of url are separated by the UrlManager-&gt;routeParam

Conventions
-----------

[](#conventions)

1. Argument is prettified only if its name is declared as action method parameter otherwise it stay in query string format;
2. Arguments are orderer by the way corresponding action method parameters are declared;
3. Optional Argument nth binds to its corresponding action method parameter only if all arguments --nth are explicitly passed. --nth argments are inserted at their respective places in created url if were nor explicit;
4. Arguments less than required or more than action method parameters show 404

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist djidji/yii2-default-url-rule "*"

```

or add

```
"djidji/yii2-default-url-rule": "*"

```

to the require section of your `composer.json` file.

Usage
-----

[](#usage)

Once the extension is installed, simply use it in your code by declaring in rules of Urlmanager :

```
'rules' => [
    // ...other url rules...
    [
        'class' => 'djidji\DefaultUrlRule',
        // complete file path to save routes.
        'routesFile' => '@app/config/routes.php'
    ],
]

```

Examples
--------

[](#examples)

```
class PostController extends Controller
{
    public function actionIndex($category,$year=2015,$tag='')
    {

    }
    public function actionView($id)
    {

    }
}

```

### To create Url

[](#to-create-url)

- `Url::to(['post/index', 'year' => 2014, 'category' => 'php'])` creates `/index.php/post/index/r/php/2014` ;
- `Url::to(['post/index', 'category' => 'php'])` creates `/index.php/post/index/r/php`;
- `Url::to(['post/index', 'category' => 'php','tag'=>'programming'])` creates `/index.php/post/index/r/php/2015/programming`. default value of parameter 'year' is inserted at its place;
- `Url::to(['post/index','year' => 2014])` result to `false` because the argument for required `$category` parameter is not passed;
- `Url::to(['post/view', 'id' => 100])` creates `/index.php/post/view/r/100` ;
- `Url::to(['post/view', 'id' => 100, 'source' => 'ad'])` creates `creates /index.php/post/view/r/100?source=ad`. Because "source" argument is not declared as actionView methoth, it is appended as a query parameter in the created URL.

### To parse Url

[](#to-parse-url)

- `/index.php/post/index` result to `false` because actionIndex has required firs parameter that need argments to be passed.
- `/index.php/post/index/r/php` is parsed to `['post/index', ['category' => 'php']]` ;
- `/index.php/post/index/r/php/2015/programming` is parsed to `['post/index', ['category' => 'php','tag'=>'programming','year'=>2015]]` ;
- `/index.php/post/index/r/php/programming` is parsed to `['post/index', ['category' => 'php','year'=>'programming']]` ;
- `/index.php/post/view/r/100?source=ad` is parsed to `['post/view', ['id' => 100]]`;
- `/index.php/post/view/r/100/ad?source=ad` result to `false` because actionView method expect one argment instead of two.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2203d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e85ead44fdb66e13c422c7b758d9252feda8117ad45ac9d5921b114eb8ccaa26?d=identicon)[djidji](/maintainers/djidji)

---

Top Contributors

[![djidji01](https://avatars.githubusercontent.com/u/19886674?v=4)](https://github.com/djidji01 "djidji01 (14 commits)")

---

Tags

yii2extensionurlmanagerprettyurlbasicUrlRule urlRuleenablePrettyUrl

### Embed Badge

![Health badge](/badges/djidji-yii2-default-url-rule/health.svg)

```
[![Health](https://phpackages.com/badges/djidji-yii2-default-url-rule/health.svg)](https://phpackages.com/packages/djidji-yii2-default-url-rule)
```

###  Alternatives

[skeeks/cms

SkeekS CMS — control panel and tools based on php framework Yii2

13825.6k47](/packages/skeeks-cms)[geertw/yii2-translatable-url-rule

A custom URL rule class for Yii 2 which allows to create translated URL rules

1420.3k](/packages/geertw-yii2-translatable-url-rule)[dmstr/yii2-cookie-consent

Yii2 Cookie Consent Widget

1452.6k](/packages/dmstr-yii2-cookie-consent)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

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