rgou/bootstrap-bundle

Twitter Bootstrap Symfony2 扩展包,包含 Doctrine ORM 和 ODM 生成器

安装次数: 48

依赖者: 0

建议者: 0

安全: 0

星标: 1

关注者: 2

分支: 0

开放问题: 0

语言:CSS

类型:symfony-bundle

v0.9.6 2013-11-01 02:56 UTC

README

建设中:此扩展包处于 alpha 阶段,尚未发布。

RgouBootstrapBundle 是将 Twitter 的 Bootstrap (http://twitter.github.com/bootstrap/) 整合到您的 symfony2 (http://www.symfony.com) 项目中。

它包含基于 SensioGeneratorBundle 的 CRUD 生成器,用于 Doctrine 和 Doctrine MongoDB ODM。

受到并借鉴了以下代码的启发:

这两个项目都非常出色!我只是想以更个性化的方式合并一些功能。

包含的功能

基本安装

rgou/bootstrap-bundle 添加到 composer.json

{
    "require": {
        // ...
        "rgou/bootstrap-bundle": "dev-master",
        // ...
    }
}

app/AppKernel.php 中注册此扩展包

public function registerBundles()
{
	$bundles = array(
		// ...
        new Rgou\BootstrapBundle\RgouBootstrapBundle(),
		// ...
	);
}

公开资源

app/console assets:install --symlink

准备 Assetic

获取 YUI 压缩器

cd /tmp
wget https://github.com/downloads/yui/yuicompressor/yuicompressor-2.4.7.zip
unzip yuicompressor-2.4.7.zip
mkdir /PAHT_TO_APPLICATION/app/Resources/java
cp /tmp/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar /PAHT_TO_APPLICATION/app/Resources/java/
rm -rf yuicompressor-2.4.7.zip yuicompressor-2.4.7

在 app/config/config.yml 中配置 Assetic

assetic:
    debug:          %kernel.debug%
    use_controller: false
    bundles:
    - RgouBootstrapBundle
    #java: /usr/bin/java
    filters:
        cssrewrite: ~
        yui_css:
            jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar
        yui_js:
            jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar

使用 assetic 编译资源

app/console assetic:dump

配置 KnpPaginatorBundle

添加到 app/config/config.yml

knp_paginator:
    page_range: 5                      # default page range used in pagination control
    default_options:
        page_name: page                # page query parameter name
        sort_field_name: sort          # sort field query parameter name
        sort_direction_name: direction # sort direction query parameter name
        distinct: true                 # ensure distinct results, useful when ORM queries are using GROUP BY statements
    template:
        pagination: KnpPaginatorBundle:Pagination:twitter_bootstrap_pagination.html.twig     # sliding pagination controls template
        sortable: KnpPaginatorBundle:Pagination:sortable_link.html.twig # sort link template

配置 KnpMenuBundle

添加到 app/config/config.yml

knp_menu:
    twig:  
        template: RgouBootstrapBundle:Menu:knp_menu.html.twig
    templating: false
    default_renderer: twig

避免 Twig 错误信息

在开发模式下,您可能会看到以下 twig 错误信息

Variable "container_class" does not exist in RgouBootstrapBundle::base.html.twig at line 13

这是因为开发环境中定义了 strict_variables 环境配置为 true

为了避免这种情况,请在以下位置中搜索

twig:
    debug:            %kernel.debug%
    strict_variables: %kernel.debug%

并更改为

twig:
    debug:            %kernel.debug%
    strict_variables: fals

更多信息: Twig - 环境选项

用法

有关完整使用说明,请参阅 文档索引