VerbUrlManager - simple extension to handle http methods in rules


Use http methods/verbs in your application rules

[b][u]how to install:


Im assuming its not the first time you are using yii’s UrlManager

To set up, download the file attached, put it in your components folder or any other folder imported in your initial configuration

and then in your configuration options (configs/main.php probably) add the following line


        	'class'=>'VerbUrlManager',//this line

        	//or 'class'=>'application.extensions.verburlmanager.VerbUrlManager'

how to use :


//rules applied to all kind of requests if a specific verbs/method rule does not match/trigger first


        //rules for post requests





        //rules for put requests










        //case insensitive





        //rule is a string, which means that all requests go to a fixed route 



extension link



Thumbs up. :)

Simple and effective.


I have followed the instructions:

  • downloaded the file

  • referenced the class in config/main.php

but can’t get it to work. I run Yii 1.1.5.

My test RESTful controller looks like:

class TestController extends Controller {


 * PUT/POST requests


public function actionCreate() {

    echo CJSON::encode(&quot;Create&quot;);



public function actionUpdate() {

    echo CJSON::encode(&quot;Update&quot;);





I use a RESTclient tool to switch between methods. If I call:

POST http://localhost/myApp/test

I’m not being routed to action create. It is kind of bypassed.

Same for POST http://localhost/myApp/test/123, not going to action update

Any idea on what I’m doing wrong? Ta

There you go, fixed, and download file updated

a little bug was causing it to ignore the routes sometimes

sorry for the incovenience

fixed bug that was causing string/fixed routes not to work properly

download file updated


I’m a TOTAL newbee.

I’d like to to for example receive a POST request with XML inside and update the DB according to the XML.

I have a controller (let’s say “controllerA”) that parses the XML and updates the tables.

Now I’d like to use your extension for the REST part. Where to start?

It would be right to create another post for your question

Anyway, this is how I would do it

the rules you use as described in the extension link or above, which is basically define routes for the different method’s type , for example if its a post and the url is /controller/3 route it to controller/update and $_GET[‘id’] would be 3

Create a class to parse the xml the way that fits your service better

in the actions in your controller do something like :



 	//do something here with the xml, like update your tables

 	//return the correct response here


Obs.: The function ispost() does not exist by default, I always create it as a shortcut for


also check out this post and this post

[center][size="3"]Note: Starting from Yii 1.1.7 this functionality is included in the core framework and should be considered obsolete.[/size][/center]