rithis / website-index-bundle
dev-master
2012-09-10 16:09 UTC
Requires
- rithis/bootstrap-bundle: @dev
This package is not auto-updated.
Last update: 2024-09-22 03:32:35 UTC
README
Symfony2 Bundle,用于在单页面上编译所有路由。
安装
在项目目录中运行此命令
$ composer.phar require rithis/website-index-bundle:@dev
之后在内核中启用此bundle
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Rithis\WebsiteIndexBundle\RithisWebsiteIndexBundle(), ); }
使用
路由
首先包括bundle路由
# app/routing.yml _rithis_website_index: resource: "@RithisWebsiteIndexBundle/Resources/config/routing.yml"
如果您想要从主页进行重定向,则添加另一条路由
# app/routing.yml _index: pattern: / defaults: { _controller: FrameworkBundle:Redirect:redirect, route: rithis_website_index_website_index_get }
带参数的路由
默认情况下,只有不带参数的路由会被编译。如果您想要添加带参数的路由,您可以配置bundle
# app/config.yml rithis_website_index: rithis_news_news_get: RithisNewsBundle:News
其中key(例如rithis_news_news_get)是路由名称,value(例如RithisNewsBundle:News)是实体。