使用Symfony架構自身提供的後台產生器,對寫後台來說,是很大的福音。它減縮了很多工作,讓注意力放到了邏輯設計上。下面是主要流程:
- 建立背景程式/管理模組
- 建立產生背景程式的設定檔
- 增加登陸模組
* 建立背景程式/管理模組
> symfony init-app backend
> symfony propel-init-admin backend post Post
> symfony propel-init-admin backend comment Comment
注意:產生管理模組與建立一般模組不同,一般模組init-module,而管理模組propel-init-admin.
其實這個與腳手架的建立類似:
symfony propel-generate-crud frontend post Post
symfony propel-generate-crud frontend comment Comment
* 建立產生背景程式的設定檔
設定檔位置:/apps/backend/modules/moduleName/config/generator.yml
具體配置資訊請參考 Symfony 權威指南14章。
* 增加登陸模組
> symfony init-module backend security
編輯apps/backend/modules/post/config/security.yml
all:
–is_secure: on
在檔案apps/backend/modules/security/templates/indexSuccess.php中,增加登陸表單。
在檔案apps/backend/modules/security/actions/actions.class.php中,增加login方法。
在檔案apps/backend/config/settings.yml中,設定登陸模組:
all:
.actions:
login_module: security
login_action: index
That is All!