# UrlRuleInterface

> UrlRuleInterface is the interface that should be implemented by URL rule classes.

[API reference](/docs/api/index.md) › [yii](/docs/api/yii/index.md) › [web](/docs/api/yii/web/index.md) › UrlRuleInterface

| interface | `yii\web\UrlRuleInterface` |
| --- | --- |
| Since | 2.0 |
| Source | [`framework/web/UrlRuleInterface.php`](https://github.com/yiisoft/yii2/blob/22.0/framework/web/UrlRuleInterface.php#L17) |

Implemented by 2 types:

- [`CompositeUrlRule`](/docs/api/yii/web/compositeurlrule/index.md)
- [`UrlRule`](/docs/api/yii/web/urlrule/index.md)

UrlRuleInterface is the interface that should be implemented by URL rule classes.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`createUrl()`](#method-createUrl) abstract | Creates a URL according to the given route and parameters. | `UrlRuleInterface` |
| [`parseRequest()`](#method-parseRequest) abstract | Parses the given request and returns the corresponding route and parameters. | `UrlRuleInterface` |

## Method details

### createUrl() <span id="method-createUrl"></span>

```php
abstract public function createUrl(yii\web\UrlManager $manager, string $route, array $params): string|bool
```

Creates a URL according to the given route and parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$manager` | [`UrlManager`](/docs/api/yii/web/urlmanager/index.md) | The URL manager |
| `$route` | `string` | The route. It should not have slashes at the beginning or the end. |
| `$params` | `array` | The parameters |

**Returns**

`string|bool`: The created URL, or false if this rule cannot be used for creating this URL.

### parseRequest() <span id="method-parseRequest"></span>

```php
abstract public function parseRequest(yii\web\UrlManager $manager, yii\web\Request $request): array|bool
```

Parses the given request and returns the corresponding route and parameters.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$manager` | [`UrlManager`](/docs/api/yii/web/urlmanager/index.md) | The URL manager |
| `$request` | [`Request`](/docs/api/yii/web/request/index.md) | The request component |

**Returns**

`array|bool`: The parsing result. The route and the parameters are returned as an array. If false, it means this rule cannot be used to parse this path info.