We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Error 404

Hello everyone I started to work in phalcon and I got first problem I created controller called SignupController.php <?php

use Phalcon\Mvc\Controller;

class SignupController extends Controller {

public function indexAction()
{

}

}

and view for that controller

in views directory

and called it index.phtml

when I going to the link I get error 404



51.2k

Not enough data for anyone to help you. Here are some tips that might be useful:

  1. Nginx or Apache ? Check this and be sure that the config files are working as expected https://docs.phalcon.io/en/latest/reference/install.html#installation-notes

  2. You should provide the code for your bootstrap and routing files - maybe we'll be able to help.

Not enough data for anyone to help you. Here are some tips that might be useful:

  1. Nginx or Apache ? Check this and be sure that the config files are working as expected https://docs.phalcon.io/en/latest/reference/install.html#installation-notes

  2. You should provide the code for your bootstrap and routing files - maybe we'll be able to help.

thats my bootstrap code and I'm using Apache

<?php

use Phalcon\Loader; use Phalcon\Mvc\View; use Phalcon\Mvc\Application; use Phalcon\DI\FactoryDefault; use Phalcon\Mvc\Url as UrlProvider; use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;

try {

// Register an autoloader
$loader = new Loader();
$loader->registerDirs(array(
    '../app/controllers/',
    '../app/models/'
))->register();

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

// Setup the view component
$di->set('view', function(){
    $view = new View();
    $view->setViewsDir('../app/views/');
    return $view;
});

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

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

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

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

edited Jul '15

in your views directory make first a directory called signup and after that put your index.phtml file. If still not working, register the routes too.

in your views directory make first a directory called signup and after that put your index.phtml file. If still not working, register the routes too.

I did that already and still not working

do you have any routing defined, and what tutorial are you following?

edited Jul '15

do you have any routing defined, and what tutorial are you following?

I'm folloiwing this tutorial https://docs.phalcon.io/en/latest/reference/tutorial.html

Is your index page working? are you going to https://yourpage/tutorial/signup/index

Put this instead of your view component in bootstrap. This will enable you to use .phtml and .volt pages

// Setup the view component
$di->set('view', function() use ($di) {
        $view = new View();
        $view->setViewsDir('../app/views/');
        $volt = new \Phalcon\Mvc\View\Engine\Volt($view, $di);
        $volt->setOptions(array(
            "compiledPath" =>  "../cache/volt/",
            "compiledSeparator" => "_"
        );
        $phtml = new \Phalcon\Mvc\View\Engine\Php($view, $di);

        $view->registerEngines([
            '.volt' => $volt,
            '.phtml' => $phtml
        ]);
        return $view;
});

If this doesn't work, then I'm quite out of ideas. You can also define the router in bootstrap. https://docs.phalcon.io/en/latest/reference/routing.html

Take a look on invo tutorial + source code. Maybe it helps

https://github.com/phalcon/invo

https://docs.phalcon.io/en/latest/reference/tutorial-invo.html