PHPackages                             fproject/yii2-restx - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. fproject/yii2-restx

ActiveYii2-extension[HTTP &amp; Networking](/categories/http)

fproject/yii2-restx
===================

Extended RESTful for Yii2 Framework

1.1.5(5y ago)72.2k5Apache-2.0PHPPHP &gt;=5.4.0

Since Mar 8Pushed 5y ago3 watchersCompare

[ Source](https://github.com/fproject/yii2-restx)[ Packagist](https://packagist.org/packages/fproject/yii2-restx)[ Docs](https://github.com/fproject/yii2-restx)[ RSS](/packages/fproject-yii2-restx/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (30)Used By (0)

yii2-restx
==========

[](#yii2-restx)

Extended Yii2 Framework RESTful for F-Project server sites

[![Latest Stable Version](https://camo.githubusercontent.com/9457d65f21c648fa8f4397df2d62cf94f5e2a45bfc512d34876ad96bffc93470/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f796969322d72657374782f762f737461626c65)](https://packagist.org/packages/fproject/yii2-restx)[![Total Downloads](https://camo.githubusercontent.com/bd19a92f5e2b2dbc81b9a5202c19d2328c90458c7e1b6a681c780670e6b2546b/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f796969322d72657374782f646f776e6c6f616473)](https://packagist.org/packages/fproject/yii2-restx)[![Latest Unstable Version](https://camo.githubusercontent.com/8569e88da8be45c304c8e1d018ac07fc3350996be3d4b76a36577f09c720e5dc/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f796969322d72657374782f762f756e737461626c65)](https://packagist.org/packages/fproject/yii2-restx)[![Build](https://camo.githubusercontent.com/548332271e755be81d225b04212a98cc5edddd09ef95243fcf5d670508fd6849/68747470733a2f2f7472617669732d63692e6f72672f6670726f6a6563742f796969322d72657374782e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/fproject/yii2-restx)[![License](https://camo.githubusercontent.com/5667698f070d033bf1c18409bd9a6a99c87c99d2975a1c4f845b4523ea77a10c/68747470733a2f2f706f7365722e707567782e6f72672f6670726f6a6563742f796969322d72657374782f6c6963656e7365)](https://packagist.org/packages/fproject/yii2-restx)

What is it?
-----------

[](#what-is-it)

#### ActiveController

[](#activecontroller)

Yii2-restx provides class `fproject\rest\ActiveController` which extends yii\\rest\\ActiveController with additional REST endpoints and methods in order to work with F-Project framework Flex clients.

By default, the following actions are supported:

- `index`: list of models. Support query criteria, pagination and sorting.
- `view`: return the details of a model
- `create`: create a new model
- `update`: update an existing model
- `delete`: delete an existing model
- `options`: return the allowed HTTP methods
- `save`: save (update or insert) a model
- `batch-save`: batch-save (update or insert) models
- `batch-remove`: batch-delete existing models

You may disable some of these actions by overriding `actions()` and unsetting the corresponding actions.

To add a new action, either override `actions()` by appending a new action class or write a new action method. Make sure you also override `verbs()` to properly declare what HTTP methods are allowed by the new action.

You should usually override `checkAccess()` to check whether the current user has the privilege to perform the specified action against the specified model.

#### UrlRule

[](#urlrule)

Yii2-RESTx also provides class `fproject\rest\UrlRule` to config URL rule for active controllers to accept extended routes.

Class UrlRule is provided to simplify the creation of URL rules for RESTful API support.

The simplest usage of UrlRule is to declare a rule like the following in the application configuration,

```
[
    'class' => 'fproject\rest\UrlRule',
    'controller' => 'user',
]
```

The above code will create a whole set of URL rules supporting the following RESTful API endpoints:

- `'PUT,PATCH users/' => 'user/update'`: update a user
- `'DELETE users/' => 'user/delete'`: delete a user
- `'GET users/remove/' => 'user/delete'`: delete a user
- `'POST users/batch-remove' => 'user/batch-remove'`: batch-remove an array of users
- `'GET,HEAD users/' => 'user/view'`: return the details/overview/options of a user
- `'POST users' => 'user/create'`: create a new user
- `'POST users/save' => 'user/save'`: save a user
- `'POST users/batch-save' => 'user/batch-save'`: save a user
- `'GET,HEAD users' => 'user/index'`: return a list/overview/options of users
- `'users/' => 'user/options'`: process all unhandled verbs of a user
- `'users' => 'user/options'`: process all unhandled verbs of user collection

You may configure `only` and/or `except` to disable some of the above rules. You may configure `patterns` to completely redefine your own list of rules. You may configure `controller` with multiple controller IDs to generate rules for all these controllers. For example, the following code will disable the `delete` rule and generate rules for both `user` and `post` controllers:

```
[
    'class' => 'fproject\rest\UrlRule',
    'controller' => ['user', 'post'],
    'except' => ['delete'],
]
```

The property `controller` is required and should represent one or multiple controller IDs. Each controller ID should be prefixed with the module ID if the controller is within a module. The controller ID used in the pattern will be automatically pluralized (e.g. `user` becomes `users`as shown in the above examples).

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

[](#installation)

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

```
composer.phar require fproject/yii2-restx:"*"

```

Usage
-----

[](#usage)

- In your Yii configuration file, use *fproject\\rest\\UrlRule* instead of *yii\\rest\\UrlRule*

```
'urlManager' => [
           'enablePrettyUrl' => true,
           'enableStrictParsing' => true,
           'rules' => [
               ['class' => 'fproject\rest\UrlRule', 'controller' => 'user'],
           ],
       ]

```

- Let your controller extends *fproject\\rest\\ActiveController* instead of *yii\\rest\\ActiveController*

```
class UserController extends \fproject\rest\ActiveController{
   public $modelClass = 'app\models\User';
}

```

Samples
-------

[](#samples)

See the sample project in this GitHub repository:

Links
-----

[](#links)

- [GitHub](https://github.com/fproject/yii2-restx)
- [Packagist](https://packagist.org/packages/fproject/yii2-restx)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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

Every ~68 days

Recently: every ~315 days

Total

29

Last Release

2162d ago

Major Versions

0.9.5 → 1.0.02015-06-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/b46aa1d9b38769bf891a8a11893d63528bb5c5fd9e3a41d5604152053e7dfee1?d=identicon)[F-Project](/maintainers/F-Project)

---

Top Contributors

[![nguyenbs](https://avatars.githubusercontent.com/u/4568193?v=4)](https://github.com/nguyenbs "nguyenbs (41 commits)")

---

Tags

restyii2restfulrestx

###  Code Quality

TestsCodeception

### Embed Badge

![Health badge](/badges/fproject-yii2-restx/health.svg)

```
[![Health](https://phpackages.com/badges/fproject-yii2-restx/health.svg)](https://phpackages.com/packages/fproject-yii2-restx)
```

###  Alternatives

[linslin/yii2-curl

Easy and nice cURL extension with RESTful support for Yii2

1811.5M20](/packages/linslin-yii2-curl)[hiqdev/yii2-hiart

ActiveRecord for API

5951.8k3](/packages/hiqdev-yii2-hiart)[zhuravljov/yii2-rest

Yii2 REST Client

1186.2k](/packages/zhuravljov-yii2-rest)[flipboxfactory/craft-rest

Rest application components for Yii2 and Craft CMS

1915.0k1](/packages/flipboxfactory-craft-rest)[tunecino/yii2-nested-rest

Adds nested resources routing support along with related actions and relationship handlers to the Yii RESTful API framework

4815.8k](/packages/tunecino-yii2-nested-rest)[simialbi/yii2-rest-client

REST client (AR-like model) for Yii Framework 2.0 (via yii2-http-client, extends ApexWire/yii2-restclient)

2232.5k](/packages/simialbi-yii2-rest-client)

PHPackages © 2026

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