I decided to try something new and installed Phalcon on Nginx (haven't used this before) and started following the Tutorial 1: Let’s learn by example.
I have created the signup link to the index page. When I click that link I'm taken to page localhost/signup but the the index page is shown (I have created app/controllers/SignupController.php and app/views/signup/index.phtml).
No matter what I write to browser's address bar, it always leads to the same result. If I type in 'localhost/some_url_that_does_not_exist' it still shows the app/views/index/index.phtml.
Dir tree:
/var/www/phalcon/
app/
controllers/
models/
views/
public/
css/
img/
js/
Nginx conf (/etc/nginx/sites-available/default):
server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
set $root_path '/var/www/phalcon/public';
root $root_path;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
Bootstrap (/var/www/phalcon/public/index.php):
<?php
try {
//Register an autoloader
$loader = new \Phalcon\Loader();
$loader->registerDirs(array(
'../app/controllers/',
'../app/models/'
))->register();
//Create a DI
$di = new Phalcon\DI\FactoryDefault();
//Setting up the view component
$di->set('view', function(){
$view = new \Phalcon\Mvc\View();
$view->setViewsDir('../app/views/');
return $view;
});
//Handle the request
$application = new \Phalcon\Mvc\Application($di);
echo $application->handle()->getContent();
} catch(\Phalcon\Exception $e) {
echo "PhalconException: ", $e->getMessage();
}
There must be some small beginner's error somewhere.