routing does not work

I started learning about routing in Phalcon.

my directory structure is :

app

--- config

------ services.php

------ config.ini

------ loader.php

looks like INVO

and I try to add :

use Phalcon\Mvc\Router;

$router = new Router();

$router->add(
    "admin/:controller/:action/:params",
    array(
        "controller" => 1,
        "action" => 2,
        "params" => 3
    )
);

but, when I try to access : http://localhost/phalcon/admin/crud/index

it give me :

AdminController handler class cannot be loaded

this page was same like http://localhost/phalcon/crud/index



1.9k

Are you sure that you have the file AdminController.php in the right place?



1.6k

I didn't write AdminController.php, because I want http://localhost/phalcon/admin/crud/index to load the same controller in http://localhost/phalcon/crud/index



31.2k

Hi,

try with:

$router = new Router(false);



1.9k

Try this:

use Phalcon\Mvc\Router;

$router = new Router();

$router->add(
    "/admin/:controller/:action/:params", // add / at the begining
    array(
        "controller" => 1,
        "action" => 2,
        "params" => 3
    )
);

I didn't write AdminController.php, because I want http://localhost/phalcon/admin/crud/index to load the same controller in http://localhost/phalcon/crud/index



1.6k

@Tao Pan @le51 It give me result : Trying to call method handle on a non-object

Maybe I missed something in my codes...



31.2k

look wich function produce that error