YII1, if the following controller is present
class extends Ccontroller { publicfunction actiongetmobilephone () { // Some code ... }}
Then, by accessing Http://your-domain-name/bind/getMobilePhone, you can access the
If the above code is accessed in Yii2, it needs to be accessed http://your-domain-name/bind/get-mobile-phone this way, because the CreateAction method is rewritten in Yii2
The createaction in YII1
Public functionCreateAction ($actionID) { if($actionID= = = "") $actionID=$this-DefaultAction; if(method_exists($this, ' action '.$actionID) &&strcasecmp($actionID, ' s '))//we have the actions method return NewCinlineaction ($this,$actionID); Else { $action=$this->createactionfrommap ($this->actions (),$actionID,$actionID); if($action!==NULL&&!method_exists($action, ' Run ')) Throw NewCException (yii::t (' Yii ', ' Action class {class} must implement the ' run ' method.Array(' {class} ' = =Get_class($action)))); return $action; } }
The createaction in Yii2
Public functionCreateAction ($id) { if($id= = = "") { $id=$this-DefaultAction; } $actionMap=$this-actions (); if(isset($actionMap[$id])) { returnYii::createobject ($actionMap[$id], [$id,$this]); } ElseIf(Preg_match('/^[a-z0-9\\-_]+$/',$id) &&Strpos($id, '--') = = =false&&Trim($id, '-') = = =$id) { //Here is the format for judging $id that is the method name $methodName= ' action '.Str_replace(‘ ‘, ‘‘,Ucwords(implode(‘ ‘,Explode(‘-‘,$id)))); //This is the name of the reorganization method if(method_exists($this,$methodName)) { $method=New\reflectionmethod ($this,$methodName); if($method->ispublic () &&$method->getname () = = =$methodName) { return NewInlineaction ($id,$this,$methodName); } } } return NULL; }
The red annotation is the difference between YII1 and YII2 in the combination of method names, YII1 is simply a combination.
Routing problems caused by action case combination in YII2 controller