2017 © Pedro Peláez
 

yii2-extension yii2-restx

Extended RESTful for Yii2 Framework

image

fproject/yii2-restx

Extended RESTful for Yii2 Framework

  • Tuesday, April 3, 2018
  • by F-Project
  • Repository
  • 3 Watchers
  • 7 Stars
  • 529 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 29 Versions
  • 7 % Grown

The README.md

yii2-restx

Extended Yii2 Framework RESTful for F-Project server sites, (*1)

Latest Stable Version Total Downloads Latest Unstable Version Build License, (*2)

What is it?

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., (*3)

By default, the following actions are supported:, (*4)

  • 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., (*5)

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., (*6)

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

UrlRule

Yii2-RESTx also provides class fproject\rest\UrlRule to config URL rule for active controllers to accept extended routes., (*8)

Class UrlRule is provided to simplify the creation of URL rules for RESTful API support., (*9)

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

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

The above code will create a whole set of URL rules supporting the following RESTful API endpoints:, (*11)

  • 'PUT,PATCH users/<id>' => 'user/update': update a user
  • 'DELETE users/<id>' => 'user/delete': delete a user
  • 'GET users/remove/<id>' => 'user/delete': delete a user
  • 'POST users/batch-remove' => 'user/batch-remove': batch-remove an array of users
  • 'GET,HEAD users/<id>' => '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/<id>' => '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:, (*12)

[
    '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)., (*13)

Installation

The preferred way to install this extension is through composer., (*14)

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

Usage

  • In your Yii configuration file, use fproject\rest\UrlRule instead of yii\rest\UrlRule, (*15)

    'urlManager' => [
            'enablePrettyUrl' => true,
            'enableStrictParsing' => true,
            'rules' => [
                ['class' => 'fproject\rest\UrlRule', 'controller' => 'user'],
            ],
        ]
    
  • Let your controller extends fproject\rest\ActiveController instead of yii\rest\ActiveController, (*16)

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

Samples

See the sample project in this GitHub repository: https://github.com/fproject/fprj-test-server-yii2, (*17)

The Versions

03/04 2018

dev-master

9999999-dev https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache-2.0 Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

03/04 2018
02/04 2018
01/04 2018

1.1.2

1.1.2.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

24/12 2016

1.1.1

1.1.1.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

24/12 2016

1.1.0

1.1.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

23/12 2016

1.0.9

1.0.9.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

01/12 2015

1.0.8

1.0.8.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

30/11 2015

1.0.7

1.0.7.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

11/11 2015

1.0.6

1.0.6.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

05/11 2015

1.0.5

1.0.5.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

21/08 2015

1.0.4

1.0.4.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

29/07 2015

1.0.3

1.0.3.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

13/07 2015

1.0.2

1.0.2.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

26/06 2015

1.0.1

1.0.1.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

01/06 2015

1.0.0

1.0.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

Apache License 2.0

The Requires

 

The Development Requires

rest yii2 restful restx

06/05 2015

0.9.5

0.9.5.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

27/04 2015

0.9.0

0.9.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

27/03 2015

0.8.0

0.8.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

26/03 2015

0.7.0

0.7.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

10/03 2015

0.6.0

0.6.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

09/03 2015

0.5.0

0.5.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

09/03 2015

0.4.0

0.4.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

09/03 2015

0.3.0

0.3.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

09/03 2015

0.2.0

0.2.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

08/03 2015

0.1.4

0.1.4.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

08/03 2015

0.1.2

0.1.2.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

08/03 2015

0.1.1

0.1.1.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx

08/03 2015

0.1.0

0.1.0.0 https://github.com/fproject/yii2-restx

Extended RESTful for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

rest yii2 restful restx