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.

Turorial 1 -> Not being served signup/index.phtml


Noob here.

I have followed tutorial 1 and have got stuck after setting the SignupController.php and view/signup/index.phtml

I have found that when clicking on the sign up link it requests "GET signup" but serves the root index.phtml not the one in /tutorial/app/views/signup/index.phtml. In bootstrap I set $url->setBaseUri('/'); as when it was tutorial I got "PhalconException: TutorialController handler class cannot be loaded"

I have found that if the controller SignupController.php isn't present then I get: PhalconException: SignupController handler class cannot be loaded. So I know that its not a problem with the controller not being seen.

What is happening is that when I click on the signup link I am getting served the route index.phtml

Please can anyone help because as far as I can see there is something wrong in the default routing performed by Phalcon.

Here is my setup: cat /etc/apache2/sites-available/000-default.conf ```php

<VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match this virtual host. For the default virtual host (this file) this # value is not decisive as it is used as a last resort host regardless. # However, you must set it for any further virtual host explicitly. #ServerName

ServerAdmin [email protected]
DocumentRoot /var/www

<Directory /var/www/>
   Options Indexes FollowSymLinks MultiViews
   AllowOverride All
   Order allow,deny
   allow from all

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

</VirtualHost> ``` cat /etc/apache2/sites-available/tutorial.conf ```php <VirtualHost *:80>

ServerAdmin [email protected]
DocumentRoot "/var/www/nbprojects/tutorial/public"
DirectoryIndex index.php

<Directory "/var/www/nbprojects/tutorial/public">
    Options All
    AllowOverride All
    Allow from all

<IfModule mod_rewrite.c>

<Directory "/var/www/nbprojects/tutorial">
    RewriteEngine on
    RewriteRule  ^$ public/    [L]
    RewriteRule  (.*) public/$1 [L]

<Directory "/var/www/nbprojects/tutorial/public">
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]


</VirtualHost> ```


try {

    $debug = new \Phalcon\Debug();

    //Register an autoloader
    $loader = new \Phalcon\Loader();

    //Create a DI
    $di = new Phalcon\DI\FactoryDefault();

    //Setup the view component
    $di->set('view', function(){
        $view = new \Phalcon\Mvc\View();
        return $view;

    //Setup a base URI so that all generated URIs include the "tutorial" folder
    $di->set('url', function(){
        $url = new \Phalcon\Mvc\Url();
        return $url;

    //Handle the request
    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

} catch(\Phalcon\Exception $e) {
     echo "PhalconException: ", $e->getMessage();

everything looks good.. what is your code in IndexController.php and SignupController.php?

Pleas use code style like described here: for your code ;)

edited Apr '14

IndexController.php ```php <?php

class IndexController extends \Phalcon\Mvc\Controller

        public function indexAction()





    class SignupController extends \Phalcon\Mvc\Controller

        public function indexAction()


ls -R tutorial ``` tutorial/: app public

controllers  models  views

IndexController.php  SignupController.php


index.phtml  signup


css  img  index.php  js





Sorry I misunderstood your problem. Adding this line to view/index.phtml should serve the problem: ```php <?php echo $this->getContent() ?> ```


Yes it does. So now I see that it serves in every call where there is a corresponding file with correctly named controller class: ```php app/views/index.phtml ``` When calling 'GET signup' it doesn't get the content of the corresponding view in app/views/signup/index.phtml.

It does display the app/views/index.phtml and where:

```php <?php echo $this->getContent() ?> ``` It shows the controller class is loaded and but only one page is getting served.

Is there something wrong with the rewrite rule in the apache config or is there a problem with getContent in bootstrap?

I'm a bit stumped here.

Everything works as it should. This is the behavior of Phalcons template engine. If app/views/index.phtml exists, Phalcon automatically uses it as your Main layout by default and getContent() injects the content (in your case: app/views/signup/index.phtml). If you delete the app/views/index.phtml, everything will still work (you can try it). I hope i could help.

read more about views:


This is good to know and it makes sense. (I tried it) Thank you for your help.

However I am left a little unsure as I have been following this:


Additionally I should have mentioned that the posted behaviour was found in osx Mavericks with Apache/2.2.24 (Unix) .

I have since installed into Ubuntu 12.04.3 LTS with Apache/2.2.22 (Ubuntu) and found that in this environment it behaves as predicted in:

edited Apr '14

In osx I succesfully setup my php and apache environment (so not as default in osx) which also allows me to compile the correct for my running php environment.

I used Patrick Bougies instructions to the letter to aid setup of this environment to feel a little more in control of my dev environment.

I had the same error mentioned above. The signup view didn't load. I realized that I have created the first view in "/views" directory initially, but in tutorial says "/views/index/" directory instead. I fixed this mistake and could load the signup page without problem!