欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Symfony2安裝第三方Bundles實(shí)例詳解

 更新時(shí)間:2016年02月04日 11:48:05   作者:Sun  
這篇文章主要介紹了Symfony2安裝第三方Bundles的方法,結(jié)合實(shí)例形式分析了Symfony2通過(guò)composer來(lái)安裝Bundle的具體步驟與相關(guān)技巧,需要的朋友可以參考下

本文實(shí)例講述了Symfony2安裝第三方Bundles的方法。分享給大家供大家參考,具體如下:

大多數(shù)的Bundles都提了安裝的介紹,下面來(lái)介紹基本的安裝步驟:

一、添加composer依賴關(guān)系

在symfony里,用composer來(lái)管理依賴關(guān)系

1.找到Bundle的包的名稱

在包的README里一般都告訴了我們它的名稱,如果沒(méi)有,可以在https://packagist.org網(wǎng)站里搜索到

2.通過(guò)composer來(lái)安裝Bundle

知道了bundle的包名之后,我們可以通過(guò)composer來(lái)安裝它

$ composer require codeguy/upload

codeguy/upload是一個(gè)上傳文件的bundle,在上一章《Symfony2使用第三方庫(kù)Upload制作圖片上傳實(shí)例詳解》中我們使用到。

執(zhí)行上面的指令,composer會(huì)給你的項(xiàng)目選擇一個(gè)最好版本的bundle,把它添加到composer.json中,并將bundle下載到vendor/目錄下。如果你想要下載一個(gè)指定的版本,在bundle的包名后增加:版本號(hào)

二、注冊(cè)Bundle

現(xiàn)在,第三方的bundle已經(jīng)安裝到你的symfony項(xiàng)目中了,在vendor/目錄下。此時(shí)我們需要在app/AppKernel.php里注冊(cè)安裝好的bundle

例如DoctrineFixturesBundle:

class AppKernel extends Kernel
{
  public function registerBundles()
  {
    $bundles = array(
      //...在這里注冊(cè)
      new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
    );
  }
  //...
}

三、配置Bundle

有的包需要一些額外的配置在 app/config/config.yml文件里。包的文檔會(huì)告訴我們關(guān)于怎樣配置,也可以通過(guò)指令來(lái)參考包的配置

$ app/console config:dump-reference

例如TwigBundle:

$ app/console config:dump-reference TwigBundle

會(huì)得到如下的提示

# 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_div_layout.html.twig
      # Example:
      - MyBundle::form.html.twig
  form_themes:
    # Default:
    - form_div_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:        ~

具體的第三方bundle安裝方法,和該bundle的使用方法都可以在它的README文件里查看。

本文永久地址:http://blog.it985.com/7059.html
本文出自 IT985博客 ,轉(zhuǎn)載時(shí)請(qǐng)注明出處及相應(yīng)鏈接。

更多關(guān)于PHP框架相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《php優(yōu)秀開發(fā)框架總結(jié)》,《codeigniter入門教程》,《CI(CodeIgniter)框架進(jìn)階教程》,《Yii框架入門及常用技巧總結(jié)》及《ThinkPHP入門教程

希望本文所述對(duì)大家基于Symfony框架的PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論