Symfony路由不运行控制器

时间:2019-06-13 08:46:17

标签: php symfony routing

我正在使用

"symfony/routing" : "^4.3",
        "symfony/yaml" : "^4.3",
        "symfony/config" : "^4.3",
        "symfony/http-foundation" : "^4.3"

我正在进入该站点(localhost:80 / foo),并且页面为空白:/就像控制器从未运行过。这里怎么了?

这是我的路由器课程-运行正常

namespace low\controller;


class Router{

    function __construct() {

        $routes = new RouteCollection();

        $filelocator = new FileLocator([__DIR__]);
        $loader = new YamlFileLoader($filelocator);
        $routes = $loader->load(__DIR__ . "/../config/routes.yaml");

        // Init RequestContext object
        $context = new RequestContext();
        $context->fromRequest(Request::createFromGlobals());

        // Init UrlMatcher object
        $matcher = new UrlMatcher($routes, $context);
        $parameters = $matcher->match($context->getPathInfo());
    }
}

路由器Yaml文件

home:
    path:       /
    controller: low\controller\MyController::fooAction
foo:
    path:       /foo
    controller: low\controller\MyController::fooAction
    methods:    GET

还有我的控制器

namespace low\controller;

class MyController{

    function fooAction(){
            echo 'anything';
            die();
    }

}

我尝试过作曲家dumpautoload -o

0 个答案:

没有答案