【发布时间】:2016-04-15 12:06:31
【问题描述】:
我正在编写自己的基于 Symfony 组件构建的 PHP 框架作为学习练习。我按照http://symfony.com/doc/current/create_framework/index.html 上的教程创建了我的框架。
我现在想使用注释将我的路由与我的控制器连接起来。我目前有以下代码来设置路由:
// Create the route collection
$routes = new RouteCollection();
$routes->add('home', new Route('/{slug}', [
'slug' => '',
'_controller' => 'Controllers\HomeController::index',
]));
// Create a context using the current request
$context = new RequestContext();
$context->fromRequest($request);
// Create the url matcher
$matcher = new UrlMatcher($routes, $context);
// Try to get a matching route for the request
$request->attributes->add($matcher->match($request->getPathInfo()));
我遇到了以下类来加载注释,但我不知道如何使用它:
如果有人可以提供帮助,我将不胜感激。
谢谢
【问题讨论】:
标签: php annotations doctrine symfony