如何在SymFony中设置默认启动模块和动作

      最近研究Symfony框架,这方面资料不是特别丰富。今天遇到一个问题,就是在哪儿设置默认启动模块,和默认启动动作。

      首先,没有默认模块供程序启用,会有如下提示信息:

Symfony Project Created

Congratulations! You have successfully created your symfony project.
Project setup successful
This project uses the symfony libraries. If you see no image in this page, you may need to configure your web server so that it gains access to the symfony_data/web/sf/ directory.
This is a temporary page
This page is part of the symfony default module. It will disappear as soon as you define a homepage route in your routing.yml.
What's next

遇到问题,切忌不看提示信息。我们看到红色加粗字体部分,是说,这个页面是Symfony框架的默认模块,它将在你定义好主页面后立即消失,主页面是在routing.yml文件中设置。

这就好了,我们去打开apps/MyApps/config/routing.yml,内容如下

homepage:
  url:   /
  param: { module: default, action: index }

default_index:
  url:   /:module
  param: { action: index }

default:
  url:   /:module/:action/*

从第一行,我们不难看出就是设置主页显示的模块和动作。把param中的default换成我们的主页模块,动作index也可以换成我们自己的动作

 

附录:

Symfony框架的中文教程 http://www.foolbirds.com/jobeet-propel-cn

还有电子图书版本:
《symfony 权威指南》 中文翻译项目  http://symfony-project.cn/cooperate/book/start

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章