安裝第三方的bundle
1,使用Composer安裝
composer require friendsofsymfony/user-bundle=》composer require bundelName
搜尋一些第三方的bundle.上面的指令會為你的專案選擇最適合的版本,如果需要製定版本使用指令
<span>$ </span>composer require friendsofsymfony/user-bundle <span>"~2.0"</span>
,並且下載程式碼到vendor目錄。
2,在AppKernel中註冊
<span>public</span><span>function</span><span>registerBundles</span><span>()</span><span>{</span><span>$bundles</span><span>=</span><span>array</span><span>(</span><span>// ...</span><span>new</span><span>FOS\UserBundle\FOSUserBundle</span><span>(),</span><span>);</span><span>// ...</span><span>}</span>
<span>class</span><span>AppKernel</span><span>extends</span><span>Kernel</span><span>{</span><span>// ...</span><span>public</span><span>function</span><span>registerBundles</span><span>()</span><span>{</span><span>$bundles</span><span>=</span><span>array</span><span>(</span><span>// ...</span><span>);</span><span>if</span><span>(</span><span>in_array</span><span>(</span><span>$this</span><span>-></span><span>getEnvironment</span><span>(),</span><span>array</span><span>(</span><span>'dev'</span><span>,</span><span>'test'</span><span>)))</span><span>{</span><span>$bundles</span><span>[]</span><span>=</span><span>new</span><span>Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle</span><span>();</span><span>}</span><span>// ...</span><span>}</span><span>}</span>
config:dump-reference AsseticBundle
以上就介紹了symfony學習筆記-bundle1,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。