Phalcon 4名称空间错误因素

时间:2020-06-25 16:34:50

标签: php namespaces phalcon phalcon-routing

我正在使用Phalcon 4.0.6,带有xampp和psr-1.0.0的php-7.4.7的Windows 10服务器版x64体系结构上。以下示例来自:“ https://docs.phalcon.io/4.0/en/application”。我无法加载控制器输出/查看输出而没有任何错误消息,它只显示空白的白页并无法找到我在做什么错。

[文件结构]

enter image description here

[index.php]

<?php
declare(strict_types=1);
error_reporting(1);
use Phalcon\Mvc\Router;
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Dispatcher;


$di = new FactoryDefault();

$loader = new Loader();
$loader->registerNamespaces(
    array(
       'Single\Controllers'    => '../app/Controllers',
    )
);

$loader->register();

$di->set('router', function(){
$router = new Router(FALSE);
$router->setDefaultNamespace('Single\Controllers');
return $router;
});

// Registering the view component
$di->set('view',function () {
        $view = new View();
        $view->setViewsDir('../app/views/');
        return $view;
    }
);
$application = new Application($di);
try {
    $response = $application->handle(
        $_SERVER["REQUEST_URI"]
    );
    $response->send();
} catch (\Exception $e) {
    echo  'Exception: ', $e->getMessage();
}

[IndexController.php]

<?php
declare(strict_types=1);

namespace Single\Controllers;

use Phalcon\Mvc\Controller;


/**
 * Class IndexController
 *
 * @property View $view
 */
class IndexController extends Controller
{
    /**
     * Welcome and user list
     */
    public function indexAction()
    {
        echo '<h1>Congratulations, you are Phlying with Phalcon!</h1>';
    }
}

0 个答案:

没有答案