安装第三方的bundle
1,使用Composer安装
composer require friendsofsymfony/user-bundle=》composer require bundelName
搜索一些第三方的bundle Packagist.org
上面的命令会为你的项目选择最合适的版本,如果需要制定版本 使用命令
<span>$ </span>composer require friendsofsymfony/user-bundle <span>"~2.0"</span>
composer.json
,并且下载代码到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>
在这个文件app/config/config.yml中进行配置
config:dump-reference AsseticBundle
以上就介绍了symfony学习笔记-bundle1,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。