Symfony2 installing a third-party bundles instance _php instance

Source: Internet
Author: User
Tags php framework codeigniter
The examples in this article describe how Symfony2 installs third-party bundles. Share to everyone for your reference, as follows:

Most of the bundles are introduced in the installation, following the basic installation steps:

First, add composer dependency relationship

In Symfony, use composer to manage dependencies

1. Find the bundle's name

In the package of the Readme generally told us its name, if not, can be found in the https://packagist.org website

2. Install bundles via composer

Once we know the bundle's name, we can install it through composer.

$ composer require codeguy/upload

Codeguy/upload is a bundle of uploaded files, which we use in the previous chapter, "Symfony2 use third-party libraries upload to make image upload examples."

Executing the above instructions, composer will select the best version of the bundle for your project, add it to the Composer.json, and download the bundle to the vendor/directory. If you want to download a specific version, add it after bundle name: Version number

Second, the registration bundle

Now, third-party bundles are already installed in your Symfony project, under the vendor/directory. At this point we need to register the installed bundles in the app/appkernel.php.

For example Doctrinefixturesbundle:

Class Appkernel extends kernel{public  function Registerbundles ()  {    $bundles = array (      //... Register here for      new Doctrine\bundle\fixturesbundle\doctrinefixturesbundle (),    );  }  //...}

Third, configure the bundle

Some packages require some additional configuration in the App/config/config.yml file. The package's documentation will tell us about how to configure it, or you can refer to the configuration of the package through instructions.

$ app/console Config:dump-reference

For example Twigbundle:

$ app/console config:dump-reference Twigbundle

You will get the following tips

# Default configuration for "Twigbundle" Twig:exception_controller: ' Twig.controller.exception:showAction ' # Deprecated since 2.6, to is removed in 3.0. Use Twig.form_themes instead form:resources: # Default:-Form_div_layout.html.twig # Example:- Mybundle::form.html.twig form_themes: # Default:-Form_div_layout.html.twig # Example:-mybundle::form.htm      L.twig Globals: # Examples:foo: "@bar" pi:3.14 # Prototype Key:id: ~ Type: ~ Value: ~ autoescape: # Defaults:-Symfony\bundle\twigbundle\twigdefaultescapingstrate   Gy-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_varia Bles: ~ auto_reload: ~ Optimizations: ~ paths: # Prototype paths: ~

The specific third-party bundle installation method, and the use of the bundle can be viewed in its readme file.

Permanent address of this article: http://blog.it985.com/7059.html
This article is from IT985 blog, please indicate the source and corresponding link when reproduced.

Read more about PHP framework related content Readers can view this site: "PHP Excellent Development Framework Summary", "CodeIgniter Introductory Tutorial", "CI (codeigniter) Framework Advanced Tutorial", "Yii framework Introduction and common skills Summary" and " thinkphp Getting Started Tutorial "

It is hoped that this article is helpful to the PHP program design based on Symfony framework.

  • 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.