How to install a third-party Bundles instance in Symfony2 _ php instance

Source: Internet
Author: User
This article mainly introduces how to install third-party Bundles in Symfony2, and analyzes the specific steps and related skills of Symfony2 using composer to install Bundle in the form of instances, for more information about how to install third-party Bundles in Symfony2, see the following example. We will share this with you for your reference. The details are as follows:

Most Bundles provide an introduction to installation. The following describes the basic installation steps:

1. Add composer dependency

In symfony, composer is used to manage dependencies.

1. Find the Bundle package name

In the README package generally tell us its name, if not, you can search in the https://packagist.org site

2. Use composer to install Bundle

After knowing the bundle package name, we can install it through composer.

$ composer require codeguy/upload

Codeguy/upload is the bundle for uploading files. It is used in the previous chapter "Symfony2 using a third-party library Upload to Create Image upload instance details.

Run the preceding command. composer selects the best bundle for your project, adds it to composer. json, and downloads the bundle to the vendor/directory. If you want to download a specified version, add the version number after the bundle package name.

Ii. Register Bundle

Now, third-party bundle has been installed in your symfony project, under the vendor/directory. Register the installed bundle in app/AppKernel. php.

For example, DoctrineFixturesBundle:

Class AppKernel extends Kernel {public function registerBundles () {$ bundles = array (//... register new Doctrine \ Bundle \ FixturesBundle \ DoctrineFixturesBundle (),);}//...}

3. Configure Bundle

Some packages require additional configuration in the app/config. yml file. The package documentation tells us how to configure the package. You can also use instructions to refer to the package configuration.

$ app/console config:dump-reference

For example, TwigBundle:

$ app/console config:dump-reference TwigBundle

The following message is displayed:

# Default configuration for "TwigBundle"twig:  exception_controller: 'twig.controller.exception:showAction'  # Deprecated since 2.6, to be removed in 3.0. Use twig.form_themes instead  form:    resources:      # Default:      - form_p_layout.html.twig      # Example:      - MyBundle::form.html.twig  form_themes:    # Default:    - form_p_layout.html.twig     # Example:    - MyBundle::form.html.twig  globals:    # Examples:    foo:         "@bar"    pi:         3.14    # Prototype    key:      id:          ~      type:         ~      value:        ~  autoescape:    # Defaults:    - Symfony\Bundle\TwigBundle\TwigDefaultEscapingStrategy    - guess  autoescape_service:  null  autoescape_service_method: null  base_template_class: ~ # Example: Twig_Template  cache:        '%kernel.cache_dir%/twig'  charset:       '%kernel.charset%'  debug:        '%kernel.debug%'  strict_variables:   ~  auto_reload:     ~  optimizations:    ~  paths:    # Prototype    paths:        ~

The specific third-party bundle installation method and usage of the bundle can be viewed in its README file.

Permanent address: http://blog.it985.com/7059.html
This article is from the IT985 blog. Please indicate the source and relevant links when reprinting.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.