We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

getParam() Problem

Using Phalcon 3.0.1 + PHP 7.0.10 on Linux.

My dispatcher in bootstrap;

use Phalcon\Mvc\Dispatcher;

$di->set('dispatcher', function() {
    $dp = new Dispatcher();
    $dp->setControllerSuffix('');
    $dp->setActionSuffix('');
    $dp->setDefaultNamespace('MyApp\Controllers');
    return $dp;
});

First issue I've seen is that I can't no longer use

$this->request->getParam('name');

I get this following error: Error: Using $this when not in object context

Even when I try using it like this;

$request = new \Phalcon\Http\Request();
$name = $request->getParam('name');

I get this following error: Error: Call to undefined method Phalcon\Http\Request::getParam()

Even using something like this wont work;

$dispatcher = new \Phalcon\Mvc\Dispatcher();
$name = $dispatcher->getParam('name');

I get blank page!

Try to remove $dp->setDefaultNamespace('MyApp\Controllers'); from your service. Also, make sure that phpinfo() returns expected Phalcon version loaded.

getParam() method does not exist in Request component, but only in Dispatcher.

public mixed getParam (mixed $param, [string|array $filters], [mixed $defaultValue]) inherited from Phalcon\Dispatcher

Gets a param by its name or numeric index