How to create routes to an admin panel

I'm starting with phalcon and I have a question. I can not create routes for an administrative panel. How can I develop a lodge to use an administrative panel? So that when the user accesses "" phalcon use the controllers that are inside a separate folder, for example:


edited May '17

Hi, the method to create "admin panel", recommended by phalcon documentation is to create multimodule (two in this case) application. For example, 'frontend' and 'admin' modules and set fronend as default module/namespace or set up phalcon router so you could omit 'fronend' in uri path. Maybe you can achieve this without multimodule app, but you probably will need different config and resources for admin part of website, so I think multimodule is better solution.

You can find the examples of multimodule applications here or check out vokuro example from documentation.

Or even better, if you have phalcon devtools installed you can do something like:

phalcon project store --name myproject --use-config-ini --type modules

In your project dir and you get your future app's sceleton.

edited May '17

        "controller" => "index",
        "action"     => "index",
        "namespace" => "namespace where IndexController of admin directory is"

But better to create multimodule app, and have proper routes for multimodules.

You don't need to create additional modules. In my opinion that's way too much work. Just setting up a generic route should work. This is one I have set up:

'/_/:controller/:action/:params'  =>   [    'namespace'  =>   'MW\Controller\Admin'
                                           ,'controller'  =>   1
                                           ,'action'      =>   2
                                           ,'params'      =>   3

With this, whenever someone goes to (for example), the controller controllers\admin\panelController.php will be used. This works because I have my autoloader set up to load based on namespaces.

Just change "/_/" to "/admin/" in my rule, and change the namespace targeted, and you should get what you need.