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

params can't be recgonized

I have a router

> $di->set('router', function () {
> 
>             $router = new \Phalcon\Mvc\Router();
> 
>             $router->add("/:module/:controller/:action/:params", array(
>                 'module' => 1,
>                 'controller' => 2, //'index',
>                 'action' => 3, //'index',
>                 'params' => 4,
>             ));
>             $router->setDefaultModule("entrance");
>             $router->setDefaultController("index");
>             $router->setDefaultAction("index");
>             $router->notFound(
>                 array(
>                     "controller" => "index",
>                     "action" => "index",
>                 )
>             );
>             return $router;
> 
>         });

but when I access

https://localhost/somemodule/somecontroller/someaction/params

warning message

Missing argument 1 for \somemodule\somecontroller\someaction

even I tried to add

echo $this->router->getMatched();

but it returns nothing

can anyone help to resolve it?

Please show yours .htaccess file.

edited Apr '15

hi, here is my htaccess file

AddDefaultCharset UTF-8

AddDefaultCharset UTF-8

<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] </IfModule>

also I tried

  echo $this->router->getModuleName (). '<br/>';
  echo $this->router->getControllerName().'<br/>';
  echo $this->router->getActionName () .'<br/>';
  var_dump( $this->router->getParams ());
  var_dump($this->dispatcher->getParams());

module, controller and action can be recgonized, but params can't be found, it returns an empty array.

now I find the root cause.

Phalcon would recgonize param 0 as null, so it's not recgonized.

usually in database, primary key would increase from 1, so this feature would not cause problem; for my application, 0 is an important parameter, so trouble for me. the solution is to modify the parameter.