PHPackages                             redkite-labs/redkite-labs-bootstrap-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. redkite-labs/redkite-labs-bootstrap-bundle

ActiveSymfony-bundle[Framework](/categories/framework)

redkite-labs/redkite-labs-bootstrap-bundle
==========================================

RedKiteLabsBootstrapBundle takes care to autoload and configure bundles on a composer base application. The responsibility to configure the bundle is delegated to the bundle's author, who implements an autoloader.json file, where declares the bundle's configuration.

v1.1.6(12y ago)95.1k1MITPHPPHP &gt;=5.3.3

Since Aug 25Pushed 11y ago2 watchersCompare

[ Source](https://github.com/redkite-labs/BootstrapBundle)[ Packagist](https://packagist.org/packages/redkite-labs/redkite-labs-bootstrap-bundle)[ Docs](http://redkite-labs.com)[ RSS](/packages/redkite-labs-redkite-labs-bootstrap-bundle/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (11)Versions (15)Used By (1)

RedKiteLabsBootstrapBundle
==========================

[](#redkitelabsbootstrapbundle)

RedKiteLabsBootstrapBundle takes care to autoload and configure Symfony2 bundles for an application which dependencies are managed by composer.

To autoload a bundle, without requiring to declare it in Symfony2's AppKernel, you just need to create an autoloader.json file on the bundle's top folder and let the RedKiteLabsBootstrapBundle do the hard job for you.

You can autoload your bundles by environments and you can add a base configuration to your bundle, saved in a config.yml file which comes with the bundle itself, to define the base configuration for your bundle the user should manually add to application's config.yml file.

As for configuration, you can define your routes in the routing.yml file and distribute them with the bundle.

[![Build Status](https://camo.githubusercontent.com/0a73a35ef491d8e6d53889bc30654b2d31dac60d37b388f83278f194245abf65/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f7265646b6974652d6c6162732f426f6f74737472617042756e646c652e706e67)](http://travis-ci.org/redkite-labs/BootstrapBundle)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/300702cd177cfc7b5c92ac4eef3e6f9b0967ba67f01cc5e53a1280acfa61028d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7265646b6974652d6c6162732f426f6f74737472617042756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f733d64333233643836666639303535633233393839633364623865306633393864313831366230326133)](https://scrutinizer-ci.com/g/redkite-labs/BootstrapBundle/)[![Code Coverage](https://camo.githubusercontent.com/fea7f7ba3e76fcfb7a007e37a6d26a0f95c888fd34529e121005036b06a8f31d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7265646b6974652d6c6162732f426f6f74737472617042756e646c652f6261646765732f636f7665726167652e706e673f733d61656230626334383761343064346136396333373664336531376265643537333062323761643531)](https://scrutinizer-ci.com/g/redkite-labs/BootstrapBundle/)

Install the RedKiteLabsBootstrapBundle
--------------------------------------

[](#install-the-redkitelabsbootstrapbundle)

To install the RedKiteLabsBootstrapBundle, simply require it in your composer.json:

```
"require": {
    [...]
    "redkite-labs/bootbusiness-theme-bundle": "dev-master"
}

```

then install/update the packages:

```
php composer.phar install/update

```

At last the bundle must be added to the AppKernel.php file:

```
public function registerBundles()
{
    $bundles = array(
        new RedKiteLabs\RedKiteCms\BootstrapBundle\RedKiteLabsBootstrapBundle(),

        [...]
    );
}

```

The autoload.json file
----------------------

[](#the-autoloadjson-file)

The autoload.json file must be placed in bundle's top folder and it is structured as follows:

- bundles (mandatory)
- routing

The mandatory **bundles** section contains the bundles you want to autoload. Let's see a very basic example:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : ""
    }
}

```

This autoloads the BusinessDropCapBundle for the whole application's environments.

### Environments

[](#environments)

When you need to autoload a bundle only for certains environments, just add the **environments** option to the bundle:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : {
            "environments" : ["dev", "test"]
        }
    }
}

```

The **environments** option enables the bundle only for the declared environments. In the example above, the BusinessDropCapBundle is enabled only for the dev and test enviroments.

### The all keyword

[](#the-all-keyword)

To specifiy all the enviroments you can use the **all** keyword:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : {
            "environments" : ["all"]
        }
    }
}

```

This is the default option used by the library when the **environments** one is not defined.

### The **overrides** options

[](#the-overrides-options)

When a bundle overrides another bundle, it must be instantiated in the AppKernel after the overrided bundle.

You can implement this case in your autoload.json adding the **overrides** option:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : {
            "environments" : ["dev", "test"],
            "overrides" : ["BusinessCarouselBundle"]
        }
    }
}

```

In this example the bundles order will be resolved instantiating the BusinessCarouselBundle before the BusinessDropCapBundle

### Autoloading a bundle without the autoloader.json file

[](#autoloading-a-bundle-without-the-autoloaderjson-file)

You might wonder why we are talking about "bundles" and not just "bundle". This is quite simple to explain, in fact you could autoload a bundle when it does not implement the autoloader.json file.

Let's suppose the BusinessCarouselBundle has not the autoloader.json file and the BusinessDropCapBundle requires it. You can write the BusinessDropCapBundle's autoloader as follows to autoload it:

For example, let's uppose the BusinessCarouselBundle requires the PropelBundle to work and this last bundle does not implements the autoloader.json file.

In this case you can easily autoload the PropelBundle just declaring that bundle in you autoload.json file:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : {
                "environments" : ["dev", "test"]
        },
        "RedKiteLabs\\Block\\BusinessCarouselBundle\\BusinessCarouselBundle" : ""
    }
}

```

If you need to enable it for specific environments, you just have to add the **environments** option as explained above.

Another situation could ben when a bundle implements its own environments. For example the RedKiteCmsBundle implements the rkcms and the rkcms\_dev environments so we need to register many thirdy part bundles:

```
{
    "bundles" : {
        "RedKiteLabs\\RedKiteCmsBundle\\RedKiteCmsBundle" : {
            "environments" : ["rkcms", "rkcms_dev", "rkcms_test", "test"]
        },
        "Propel\\PropelBundle\\PropelBundle" : {
            "environments" : ["rkcms", "rkcms_dev", "rkcms_test", "test"]
        },
        "Symfony\\Bundle\\WebProfilerBundle\\WebProfilerBundle" : {
            "environments" : ["rkcms_dev", "rkcms_test"]
        },
        "Sensio\\Bundle\\DistributionBundle\\SensioDistributionBundle" : {
            "environments" : ["rkcms_dev", "rkcms_test"]
        },
        "Sensio\\Bundle\\GeneratorBundle\\SensioGeneratorBundle" : {
            "environments" : ["rkcms", "rkcms_dev", "rkcms_test"]
        }
    }
}

```

The **"RedKiteLabs\\RedKiteCmsBundle\\RedKiteCmsBundle"** section enables the RedKiteCmsBundle for the **"rkcms", "rkcms\_dev", "rkcms\_test", "test"**, then requires the PropelBundle for the same environments and at last requires the WebProfilerBundle, the SensioDistributionBundle and the SensioGeneratorBundle for the **"rkcms\_dev", "rkcms\_test"** environments.

Configuration files (config.yml - routing.yml)
----------------------------------------------

[](#configuration-files-configyml---routingyml)

Usually each bundle requires to add some configurations inside the application's config.yml to make it work properly. Some of these settings could be generic, ie. enabling the bundle to use assetic, while others could be specific for the application which is using that bundle.

The **BootstrapBundle** let the developer to define the generic settings directly with the bundle. This will produce some benefits for the final user:

- The bundle that requires only generic setting is ready to be used without touching the application's config.yml file
- When the bundle is used by many applications, the generic configuration is already made
- Less frustation for the user
- Less frustation for the bundle's developer who has to write less documentation
- Light config.yml file

To add a configuration that usually goes into the application's **config.yml** file, just add a **config.yml** file under the **Resources/config** folder of your bundle and add the required setting to it.

The BootstrapBundle takes care to copy it into the **app/config/bundles/\[environment\]**folder and load your configuration in the AppKernel class.

The same concepts are applied to the routes implemented by the bundle, so you can add a **routing.yml** file into the **Resources/config** of your bundle and the BootstrapBundle will do the rest for you.

Routing priority
----------------

[](#routing-priority)

When you need to assign a specific priority to routing files, you can add a **routing/priority**setting to your configuration file:

```
{
    "bundles" : {
        "RedKiteLabs\\Block\\BusinessDropCapBundle\\BusinessDropCapBundle" : ""
    },
    "routing" : {
        "priority" : "128"
    }
}

```

Each bundle gets zero as routing priority when the option is not specified. To load the routing file after, specify a value higher than zero, to load the routing file before, specify a value lower than zero.

### A practical example

[](#a-practical-example)

For example, RedKiteCmsBundle uses assetic to manage its assets, so the user who want to use that bundle should add the following configuration to the config.yml file of his application:

```
app/config/config.yml

assetic:
bundles: [RedKiteLabsCmsBundle]
filters:
    cssrewrite: ~
    yui_css:
        jar: %kernel.root_dir%/Resources/java/yuicompressor.jar
    yui_js:
        jar: %kernel.root_dir%/Resources/java/yuicompressor.jar

```

With the BootstrapBundle these setting have been added to RedKiteCmsBundle's config.yml file so the user is not required to manually add those settings to application's config.yml.

Enabling the routing autoloader
-------------------------------

[](#enabling-the-routing-autoloader)

To enable the routing autoloader the following configuration must be added to the application's **routing.yml** configuration file:

```
RedKiteLabsBootstrapBundle:
    resource: .
    type: bootstrap

```

Use the BootstrapBundle in your AppKernel
-----------------------------------------

[](#use-the-bootstrapbundle-in-your-appkernel)

To enable the autoloading some small changes must be implemented to the AppKernel file. At the end of the **registerBundles** method, declare a new **BundlesAutoloader** object, as follows:

```
public function registerBundles()
{
    $bundles = array(
        [...]
    );

    if (in_array($this->getEnvironment(), array('dev', 'test'))) {
        [...]
    }

    $bootstrapper = new \RedKiteLabs\RedKiteCms\BootstrapBundle\Core\Autoloader\BundlesAutoloader(__DIR__, $this->getEnvironment(), $bundles);
    $bundles = $bootstrapper->getBundles();

    return $bundles;
}

```

BundlesAutoloader requires the kernel dir, the one where the AppKernel is placed, as first argument, the current environment as second argument and the instantiated bundles as third.

Bundles are retrieved by the **getBundles** method and returned as usual.

To load the configurations from the app/config/bundles folder, the default **registerContainerConfiguration** must be changed as follows:

```
public function registerContainerConfiguration(LoaderInterface $loader)
{
    $configFolder = __DIR__ . '/config/bundles/config/' . $this->getEnvironment();
    if (is_dir($configFolder)) {
        $finder = new \Symfony\Component\Finder\Finder();
        $configFiles = $finder->depth(0)->name('*.yml')->in($configFolder);
        foreach ($configFiles as $config) {
            $loader->load((string)$config);
        };
    };

    $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
}

```

### Autoload bundles from other folders

[](#autoload-bundles-from-other-folders)

BundlesAutoloader can be configured to look for autoloading bundles placed inside other folders in your application.

By defaut the BundlesAutoloader looks into the **src/RedKiteCms/Block** and the **src/RedKiteCms/Theme** folders.

You can easily change that parameter, passing an array with your folders defined into to the BundlesAutoloader declaration.

For example, if you would need to tell BundlesAutoloader to look into the **src/Acme**just change the BundlesAutoloader instantiation as follows:

```
$bootstrapper = new \RedKiteLabs\BootstrapBundle\Core\Autoloader\BundlesAutoloader(__DIR__, $this->getEnvironment(), $bundles, array(__DIR__ . '/../src/Acme');

```

Please notice that the BundlesAutoloader assumes that your bundles are placed inside the **Acme** folder.

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 94.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Recently: every ~0 days

Total

15

Last Release

4461d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/543f3609df36d46fa28192465eba07e9d0a64af1c5798caf03647d97cf5c99f6?d=identicon)[redkite-labs](/maintainers/redkite-labs)

---

Top Contributors

[![alphalemon](https://avatars.githubusercontent.com/u/1242258?v=4)](https://github.com/alphalemon "alphalemon (36 commits)")[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (2 commits)")

---

Tags

bundleautoloadbootstrapredkite labs

### Embed Badge

![Health badge](/badges/redkite-labs-redkite-labs-bootstrap-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/redkite-labs-redkite-labs-bootstrap-bundle/health.svg)](https://phpackages.com/packages/redkite-labs-redkite-labs-bootstrap-bundle)
```

###  Alternatives

[yiisoft/yii2-bootstrap

The Twitter Bootstrap extension for the Yii framework

18320.2M1.0k](/packages/yiisoft-yii2-bootstrap)[league/tactician-bundle

Bundle to integrate Tactician with Symfony projects

24910.4M18](/packages/league-tactician-bundle)[friendsofcake/bootstrap-ui

Bootstrap front-end framework support for CakePHP

3522.2M39](/packages/friendsofcake-bootstrap-ui)[yiisoft/yii2-bootstrap4

The Twitter Bootstrap extension for the Yii framework

2173.4M189](/packages/yiisoft-yii2-bootstrap4)[yiisoft/yii2-bootstrap5

The Twitter Bootstrap v5 extension for the Yii framework

661.6M131](/packages/yiisoft-yii2-bootstrap5)[matthiasnoback/symfony-bundle-plugins

Allow Symfony bundles to have plugins

598.1k2](/packages/matthiasnoback-symfony-bundle-plugins)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
