new to CraftCMS - I'm building a website that has to handle two different APIs, where the user logs into API-1 and after succeeding the website has to call an other API checking for a status while using data that was returned from the first API.

I started to set-up two controllers to handle the requests of each API separately. What I have to do is to fire an action from controller-1 (login-callback) and if login was ok I would like to directly fire an action from controller-2 handling the second API (without the user having to take action by clicking a button). Some research showed that I can do


That works so far but I have to pass some data as params and found out that the call then should look like:

Craft::$app->runAction('mymodule/contoller/method-name-call', ['foo' => 'bar']);

But I can't manage to access the passed arguments :/ Even tried to pass to pass as a GET-Param like:


and then access via:

$request = Craft::$app->getRequest();
$data = $request->get('foo');

but no success..

Can somebody advice me how to access the passed params in my case?

1 Answer 1


After crawling the Yii repository issues I found out how to pass and retrieve the arguments.

In case someone else is struggeling with this I'd like to share this little summary:

# Controller-1
public function actionSomeMethodName()
    // call action of controller-2
    Craft::$app->runAction('mymodule/controller-2/method-other-controller', ['paramsWrapperName' => ['someKey' => 'some value'] ]);

    // do something ...

The argument-name $paramsWrapperName has to match the outter-array-index where you make the call and you have to type-cast the argument as array otherwise you get a baaaaaad baad exception

# Controller-2
public function actionMethodOtherController(array $paramsWrapperName)
    // do something with $paramsWrapperName

Of course instead of paramsWrapperName a simple params or simular makes more sense, just wanted to make it clearer that way..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.