我有一个更新网站的任务。本网站使用Symfony2。我尝试在我的localhost上模拟网站。
当我尝试使用空方向路径(REQUEST_URI)到达索引页面时
Symfony2返回No route found for "GET /"
。我尝试运行的网址是http://localhost/app_dev.php
。
当我使用(例如)/booking
时,它也无法正常工作
有什么问题?
app / config / routing.yml:
app: resource: "@AppBundle/Controller/" type: annotation
app / config / routing_dev.yml:
_wdt: resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" prefix: /_wdt _profiler: resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" prefix: /_profiler _configurator: resource: "@SensioDistributionBundle/Resources/config/routing/webconfigurator.xml" prefix: /_configurator _errors: resource: "@TwigBundle/Resources/config/routing/errors.xml" prefix: /_error _main: resource: routing.yml
src / AppBundle / Resources / config / routing.yml:
AppBundle: resource: "@AppBundle/Resources/config/routing/routing.yml" prefix: / AppBundle_booking: resource: "@AppBundle/Resources/config/routing/booking.yml" prefix: /bookings AppBundle_client: resource: "@AppBundle/Resources/config/routing/client.yml" prefix: /clients AppBundle_invoice: resource: "@AppBundle/Resources/config/routing/invoice.yml" prefix: /invoices AppBundle_product: resource: "@AppBundle/Resources/config/routing/product.yml" prefix: /products AppBundle_category: resource: "@AppBundle/Resources/config/routing/category.yml" prefix: /categories AppBundle_contracts: resource: "@AppBundle/Resources/config/routing/contract.yml" prefix: /contracts AppBundle_users: resource: "@AppBundle/Resources/config/routing/user.yml" prefix: /users AppBundle_activities: resource: "@AppBundle/Resources/config/routing/activity.yml" prefix: /activities AppBundle_services: resource: "@AppBundle/Resources/config/routing/service_contract.yml" prefix: /services
src / AppBundle / Resources / config / routing / routing.yml:
AppBundle_home: pattern: / defaults: { _controller: AppBundle:Default:index }
我知道还有很多与我相似的问题。但是,当我试图遵循给定答案的分数时,它仍然无效。所以我希望这会对我有所帮助。
提前致谢。
答案 0 :(得分:2)
在 app / config / routing.yml 文件中,您将注释定义为路由配置类型。但是,您正在使用YML文件来配置路由。
将 app / config / routing.yml 更改为:
app:
resource: "@AppBundle/Resources/config/routing/routing.yml"
应正确加载捆绑包的路由配置。