如何使用内置web服务器在Symfony 4中运行子域?
我读了以下关于子域的文章 我的控制器文件夹结构是:如何使用内置web服务器在Symfony 4中运行子域?,symfony,Symfony,我读了以下关于子域的文章 我的控制器文件夹结构是: src/控制器/管理员 src/控制器/主控制器 所有管线都是在控制器文件中使用注释定义的 例: 因此,我在config/routes.yaml文件中添加了以下配置: #config/routes.yaml main: host: "localhost" resource: ../src/Controller/Main type: annotation admin: host: "admin.localhos
- src/控制器/管理员
- src/控制器/主控制器
#config/routes.yaml
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
#config/routes.yaml
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
我想要的是:
- 访问=> src/Controller/Admin/HomeController中的主页方法
- 访问=> src/Controller/Main/HomeController中的主页方法
#config/routes.yaml
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
#config/routes.yaml
admin:
host: "admin.localhost"
resource: ../src/Controller/Admin
type: annotation
main:
host: "localhost"
resource: ../src/Controller/Main
type: annotation
工作并获得404的欢迎信息
如何使用运行。我使用此命令行进行调试 php bin/控制台调试:路由器 由于名称相同,只有最后一个名称为:
@Route("/", name="home")
我只是更改了管理员的名字
@Route("/", name="admin-home")
现在它可以工作了您是如何将
project\u demo.test
指向内置服务器的?您对子域也做了同样的操作吗?我只是运行bin/console server:start,并对这两个服务器(admin.localhost和localhost)使用相同的命令