symfony study notes-bundle1

WBOY
Release: 2016-07-29 08:57:08
Original
1079 people have browsed it

Install a third-party bundle

1. Use Composer to install

composer require friendsofsymfony/user-bundle=》composer require bundelName
Copy after login
bundleName: a. Readme file of the project b. Search Packagist.org on the website

Search for some third-party bundles Packagist.org

The above command will select the most appropriate version for your project. If you need to specify a version, use the command

<span>$ </span>composer require friendsofsymfony/user-bundle <span>"~2.0"</span>
Copy after login
. The command execution is completed, add the content to composer.json, and download the code to the vendor directory.

2. Register in 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>
Copy after login
If you only want to use the bundle in development mode or test mode, the registration method is as follows
<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>
Copy after login
3, configure bundle

Configure in this file app/config/config.yml

config:dump-reference AsseticBundle
Copy after login
The above command can display the AsseticBundle configuration manual (reference)

The above introduces the symfony study notes-bundle1, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!