CakePHP: GET Current Controller, Action and Parameters


Request Parameters


To get the current controller:

$controllerName = $this->request->getAttribute('controller');

To get the current action:

$acctionName= $this->request->getAttribute('action');

To get all passed arguments as a numerically indexed array:

http://localhost/calendars/view/recent/mark
$parameters = $this->request->getParam('pass');
Array
(
    [0] => recent
    [1] => mark
)

Query String Parameters


// URL is /posts/index?page=1&sort=title
$page = $this->request->getQuery('page');







Comments

Popular posts from this blog

CakePHP 4: Firebase Cloud Messaging Component in CakePHP for Push Notification

CakePHP 4 : Using Component inside Command ( Shell )

LIMIT SSH ACCESS BY COUNTRY