Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Fullcontrol routing and rendering view

I'm pretty new with php frameworks, my only experience was Laravel, and though it's enjoyable, laravel isn't what I really want. After some search, I found out about Yaf and Phalcon which is really close to what I had in mind, a simple MVC architecture with speed.

Yaf document isn't that good, so I decided to stick with Phalcon. The INVO tutorial is good enough, but the thing is that, because my lacking of experience with php and all, I couldn't find the way to disable auto routing (controller/action/params) and instead map the route manually (to get the full control with the URI).

The other thing, I'd like to have full control with what views I would like to render (not the default controller = view convention), because sometime I would like to have a dynamic sidebar defending on the content of the site ( I know this could be achieve by using library, but I'd like to put any html in views (like it does in Laravel) to separate the logic and view to make it more maintainable.

Thanks for help.

edited Mar '14

// Create the router without default routes
$router = new \Phalcon\Mvc\Router(false);
// then use any patter you want
        "controller" => "posts",
        "action"     => "show",
        "year"       => 1,
        "month"      => 2,
        "title"      => 4

You can use to find out all the methods you can use. There is a methods to change or to disable any of the layers: They can be used directly inside the controller or action, so you can build the view dynamically.

class IndexController extends Phalcon\Mvc\Controller
    public function indexAction()
        // use /views/sign/in.phtml instead of /views/index/index.phtml as action layer
        // don't use /views/layouts/index.phtml

You can use partials to build view from smaller parts, with needed conditions as well:

<!DOCTYPE html>
        <title>Blog's title</title>
<?php if ($this->session->has('auth')) $this->partial("additional/user-authed-panel") ?>