user2940867
user2940867

Reputation:

zend framework 2 controller's action arguments

I had this public function in ApplicationController

public function indexAction($bar) {
    echo $bar; 
    return new ViewModel();
}

How I can pass this argument? I've tried http://localhost/zf2/public/application/index/index?bar=foo but this not works

Upvotes: 0

Views: 45

Answers (1)

venca
venca

Reputation: 1222

Grab it from params controller plugin.

public function indexAction()
{
    $bar = $this->params()->fromQuery('bar');
    return new ViewModel();
}

Upvotes: 1

Related Questions