我读到这个子域下doc。
我的控制器文件夹结构为:
所有路由都在控制器中的文件注释中定义。
例如:
#src/Controller/Admin/HomeController.php
class HomeController extends AbstractController
{
/**
* @Route("/", name="home")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function homepage(){...}
}
#src/Controller/Main/HomeController.php
class HomeController extends AbstractController
{
/**
* @Route("/", name="home")
* @return \Symfony\Component\HttpFoundation\Response
*/
public function homepage(){...}
}
所以我加入的config / routes.yaml文件此以下配置:
#config/routes.yaml
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
我要的是:
斌/控制台服务器:启动
但是,只有http://admin.localhost/工程和http://localhost/本以下消息得到404:“欢迎来到Symfony的4.2.2”
如果我换在YAML文件中的顺序:
#config/routes.yaml
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
http://localhost/工程和http://admin.localhost/得到404与欢迎信息
我怎么可以用subdomain运行built-in web server。
我调试通过使用此命令行
PHP斌/控制台调试:路由器
因为同一个名字的,只有最后已经阅读:
@Route("/", name="home")
我只是改名字为管理员
@Route("/", name="admin-home")
现在,它的工作原理