如何在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

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