PHP Annotation路由实现研究
<?php
class Controller
{
/**
* @Route("/index")
*/
public function index()
{
echo 'index';
}
/**
* @Route("/go")
*/
public function go()
{
echo 'go';
}
}
$controller = new Controller();
$a = new ReflectionClass($controller);
foreach ($a->getMethods() as $method) {
preg_match("/@Route\(\"(.+)\"\)/", $method->getDocComment(), $ret);
var_dump($ret[1]);
}