将子域路由添加到 Symfony 时出现 FileLoaderImportCircularReferenceException
FileLoaderImportCircularReferenceException when adding subdomain routing to Symfony
我正在尝试将子域路由到 Symfony2 中的特定包。这是我得到的:
我将本地域添加到我的主机:
127.0.0.1 todolist.lc
127.0.0.1 manager.todolist.lc
我创建了一个将所有子域转发到我的 Symfony 安装的虚拟主机:
<VirtualHost 127.0.0.1>
ServerName todolist.lc
ServerAlias *.todolist.lc
DirectoryIndex app_dev.php
DocumentRoot "C:\xampp\htdocs\todolist\web"
</VirtualHost>
我创建了一个新的 Bundle 来处理子域 manager.todolist.lc:
现在我正在尝试设置通往 manager.todolist.lc:
的路线
frontend:
resource: "@FrontendBundle/Controller/"
type: annotation
prefix: /
backend:
resource: "@BackendBundle/Controller/"
type: annotation
prefix: /api
manager:
host: manager.todolist.lc
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /
现在,在我添加管理器路由后,我在每条路由上都得到了一个 FileLoaderImportCircularReferenceException。
我也试过使用前缀,但这也给出了异常:
manager:
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /manager
我不知道我错过了什么。我究竟做错了什么?如果您需要更多信息,请在评论中提出,我会提供。
好的。这是我遗漏的内容:
1.我忘了将包加载到 AppKernel
显然,这很重要:
new FrontendBundle\FrontendBundle(),
new BackendBundle\BackendBundle(),
new ManagerBundle\ManagerBundle(),
2。子域需要在主域之前声明
在我将包加载到 AppKernel 之后,应用程序仍会路由到 FrontController。我通过更改路线顺序解决了这个问题:
manager:
host: manager.todolist.lc
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /
frontend:
resource: "@FrontendBundle/Controller/"
type: annotation
prefix: /
backend:
resource: "@BackendBundle/Controller/"
type: annotation
prefix: /api
更改路由顺序后,manager.todolist.lc 和 todolist.lc 均有效。
我正在尝试将子域路由到 Symfony2 中的特定包。这是我得到的:
我将本地域添加到我的主机:
127.0.0.1 todolist.lc
127.0.0.1 manager.todolist.lc
我创建了一个将所有子域转发到我的 Symfony 安装的虚拟主机:
<VirtualHost 127.0.0.1>
ServerName todolist.lc
ServerAlias *.todolist.lc
DirectoryIndex app_dev.php
DocumentRoot "C:\xampp\htdocs\todolist\web"
</VirtualHost>
我创建了一个新的 Bundle 来处理子域 manager.todolist.lc:
现在我正在尝试设置通往 manager.todolist.lc:
的路线frontend:
resource: "@FrontendBundle/Controller/"
type: annotation
prefix: /
backend:
resource: "@BackendBundle/Controller/"
type: annotation
prefix: /api
manager:
host: manager.todolist.lc
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /
现在,在我添加管理器路由后,我在每条路由上都得到了一个 FileLoaderImportCircularReferenceException。
我也试过使用前缀,但这也给出了异常:
manager:
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /manager
我不知道我错过了什么。我究竟做错了什么?如果您需要更多信息,请在评论中提出,我会提供。
好的。这是我遗漏的内容:
1.我忘了将包加载到 AppKernel
显然,这很重要:
new FrontendBundle\FrontendBundle(),
new BackendBundle\BackendBundle(),
new ManagerBundle\ManagerBundle(),
2。子域需要在主域之前声明
在我将包加载到 AppKernel 之后,应用程序仍会路由到 FrontController。我通过更改路线顺序解决了这个问题:
manager:
host: manager.todolist.lc
resource: "@ManagerBundle/Controller/"
type: annotation
prefix: /
frontend:
resource: "@FrontendBundle/Controller/"
type: annotation
prefix: /
backend:
resource: "@BackendBundle/Controller/"
type: annotation
prefix: /api
更改路由顺序后,manager.todolist.lc 和 todolist.lc 均有效。