Symfony2 Install the third party bundles instance detailed _php instance

Source: Internet
Author: User
Tags php framework codeigniter

The example in this article describes the method for installing a third-party bundles Symfony2. Share to everyone for your reference, specific as follows:

Most bundles have an introduction to installation, and the following are the basic installation steps:

First, add composer dependencies

In Symfony, use composer to manage dependencies

1. Find the name of the bundle package

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

2. Install bundle via composer

After we know bundle's package name, we can install it through composer.

$ composer require codeguy/upload

Codeguy/upload is an upload file of the bundle, in the previous chapter "Symfony2 Use the Third-party library upload to create pictures Upload example detailed" we use.

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

Second, register bundle

Now, the third party bundle has been installed into your symfony project, under the vendor/directory. At this point we need to register the installed bundle in app/appkernel.php.

For example Doctrinefixturesbundle:

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

Third, the configuration bundle

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

$ app/console Config:dump-reference

For example Twigbundle:

$ app/console config:dump-reference Twigbundle

Will get the following tips

# Default configuration for "Twigbundle" Twig:exception_controller: ' twig.controller.exception:showAction ' # Depreca Ted since 2.6, to being 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:-Mybund
      Le::form.html.twig Globals: # Examples:foo: "@bar" pi:3.14 # Prototype key: ID: ~ Type: ~ Value: ~ autoescape: # Defaults:-symfony\bundle\twigbundle\t Wigdefaultescapingstrategy-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: ~

 

Specific Third-party bundle installation methods, and the use of the bundle can be viewed in its readme file.

This article permanent address: http://blog.it985.com/7059.html
This article comes from IT985 blog, reprint, please indicate the source and corresponding link.

For more information about PHP framework interested readers can view the site topics: "PHP Excellent Development Framework Summary", "CodeIgniter Introductory Course", "CI (CodeIgniter) Framework Advanced Course", "Yii framework Introduction and common skills Summary" and " thinkphp Getting Started Tutorial "

I hope this article will help you with 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.