Yii2 calls interface across controllers?

how can yii2 be called across controller calling interfaces, and parameters can be passed in.

Mar.05,2021

I usually use curl


Yii2.0 can be called across controllers using the runaction method.

$result = \Yii::$app->runAction(['user/login']);

1. Try to seal the method as static as possible, so that the controller of other words directly :: calls
2, and you can use trait to solve the problem of methods called across controllers. The method to be called is placed in trait


.

here I choose curl, to share with you the curl method

clipboard.png
in this way, there may be more code. If you use cross-controller calls, or jump methods, you should be able to do it with one line of code.

Menu