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

Views not being displayed in non-default config help pleas

I generated a project using, phalcon tools. In the config.php I changes view to:

'viewsDir' => APP_PATH . '/views/test/',

I have created two controllers: ExampleController and TestController

I have links pointing to https://example.com/test and https://example.com/test

In the views folder I have placed 2 files, one in views/test/example/example.phtml and another in views/test/test/test.phtml when I try to go to the links I get a blank page, if I move the phtml files in folder views/test/ the view that is loaded is the index.phml no matter which of the 2 url's I go to (this is the page that displays the 2 links above). If I echo out from the controllers this is displayed so the controllers are being accessed just the view are not being displayed. Please can someone advise? (Nb. If I use the default view configuration, then the views are being displayed)

It's a problem with you view service config, check the docs or share your config file

Please don't spam the boards with 4 identical posts. I've deleted all except this one.



6.6k

Sorry wasn't attempting to spam every time I submitted I got a 500 error on the forum.



6.6k
edited Mar '18

My config file is as follows:


<?php defined('BASE_PATH') || define('BASE_PATH', getenv('BASE_PATH') ?: realpath(dirname(__FILE__) . '/../..'));
defined('APP_PATH') || define('APP_PATH', BASE_PATH . '/app');
return new \Phalcon\Config([
    'database' => [
        'adapter'     => 'Mysql',
        'host'        => 'localhost',
        'username'    => 'root',
        'password'    => '',
        'dbname'      => 'test',
        'charset'     => 'utf8',
    ],
    'application' => [
        'appDir'         => APP_PATH . '/',
        'controllersDir' => APP_PATH . '/controllers/',
        'modelsDir'      => APP_PATH . '/models/',
        'migrationsDir'  => APP_PATH . '/migrations/',
        'viewsDir'       => APP_PATH . '/views/test/',
        'pluginsDir'     => APP_PATH . '/plugins/',
        'libraryDir'     => APP_PATH . '/library/',
        'cacheDir'       => BASE_PATH . '/cache/',
        'baseUri'        => preg_replace('/public([\/\\\\])index.php$/', '', $_SERVER["PHP_SELF"]),
    ]
]);```


6.6k
Accepted
answer

Hi, I deleted the project and recreated it and things seem to working. Ican only assume that there was maybe a permissions problem.