symfony初學者必須掌握的知識


講解如何生成數據表及創建Bunlde

==== 開啟 app.php
$kernel = new AppKernel('prod', false);
改為
$kernel = new AppKernel('prod', true);

==== 模版 設定url
如果是圖片等靜態文件: asset('test/path'); 不要已/ 開頭
如果是程序(Controller): path('_name'); _name 可以是本bundle內Controller 定義的。 還可以是 routing.yml 文件中定義

==== 創建一個 Bundle
generate:bundle

==== 登錄
http://symfony.com/doc/current/cookbook/security/entity_provider.html
在參照上面url 做測試的時候
如果加密方式為 sha512。 則 password 的長度為 88 。 需要更改數據庫結構

==== 生成Entity
generate:doctrine:entity 

==== 更新Entity或生成 Repository
console doctrine:generate:entities IntergroupCrmBundle:Department

==== 更新數據庫
doctrine:schema:update --force

==== 數據表關聯
http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/association-mapping.html

one-to-one 有三種情況。因為Doctrine 會根據設定來創建外鍵!


==== ot
http://symfony.com/doc/current/book/doctrine.html

==== 嵌套FORM
保存的時候 必須互相關聯
$user = new \Intergroup\CrmBundle\Entity\User();
        $info = new \Intergroup\CrmBundle\Entity\UserInfo();
        $info->setUser($user);
        $user->setInfo($info);
發佈了28 篇原創文章 · 獲贊 0 · 訪問量 9899
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章