PHPackages                             elboletaire/twbs-cake-plugin - 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. [Templating &amp; Views](/categories/templating)
4. /
5. elboletaire/twbs-cake-plugin

AbandonedArchivedCakephp-plugin[Templating &amp; Views](/categories/templating)

elboletaire/twbs-cake-plugin
============================

Twitter Bootstrap Plugin for CakePHP 3 with bundled less.php and less.js parsers, helpers and bake templates

v3.4.1(9y ago)2662.3k↑111.1%10[1 issues](https://github.com/elboletaire/twbs-cake-plugin/issues)MITCSS

Since Oct 6Pushed 8y ago9 watchersCompare

[ Source](https://github.com/elboletaire/twbs-cake-plugin)[ Packagist](https://packagist.org/packages/elboletaire/twbs-cake-plugin)[ Docs](https://github.com/elboletaire/twbs-cake-plugin)[ RSS](/packages/elboletaire-twbs-cake-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (9)Dependencies (3)Versions (16)Used By (0)

Bootstrap plugin for CakePHP 3.X
================================

[](#bootstrap-plugin-for-cakephp-3x)

[![License](https://camo.githubusercontent.com/55edc4b7c04d491d31ebf3af72130245e69f2a9adadca3f828d2e32b09b852c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f656c626f6c6574616972652f747762732d63616b652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/elboletaire/twbs-cake-plugin/blob/master/LICENSE)[![Latest Stable Version](https://camo.githubusercontent.com/e1423bd97cb28e2871edcb269e934e7dffc57320c94e5810476e0df08ca64552/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656c626f6c6574616972652f747762732d63616b652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://github.com/elboletaire/twbs-cake-plugin/releases)[![Total Downloads](https://camo.githubusercontent.com/a7c458237fb1b85c9c6bdd7fc0ab7add9cd1caef0b84c8e0f861338caaf984c1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656c626f6c6574616972652f747762732d63616b652d706c7567696e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/elboletaire/twbs-cake-plugin/stats)

This plugin includes both [less.js](http://lesscss.org/#client-side-usage-browser-options) and [less.php](https://github.com/oyejorge/less.php#lessphp) parsers and allows you to easilly deploy CakePHP applications with (Twitter) [Bootstrap](https://github.com/twbs/bootstrap).

Since version 3.0.2 this plugin dropped its own helpers and components and added [friendsofcake/bootstrap-ui](https://github.com/FriendsOfCake/bootstrap-ui) as a composer requirement, so you will use all their classes instead.

It also contains bake templates that will help you starting *twitter-bootstraped*CakePHP webapps.

General Features
----------------

[](#general-features)

- Parses less files using less.js and/or less.php.
- LessHelper to easily parse files.
- Bake templates.
- Generic Bootstrap layout.
- All the included utilities from BootstrapUI plugin.

Installation
------------

[](#installation)

### Adding the plugin

[](#adding-the-plugin)

You can easily install this plugin using composer as follows:

```
composer require elboletaire/twbs-cake-plugin
```

After doing it, composer will ask you for a version. Checkout the [package on packagist](https://packagist.org/packages/elboletaire/twbs-cake-plugin) to know every available version.

### Enabling the plugin

[](#enabling-the-plugin)

After adding the plugin remember to load it in your `config/bootstrap.php` file:

```
Plugin::load('Bootstrap', ['bootstrap' => true]);
```

This will load the Less and BootstrapUI plugins for you.

If you preffer to do this manually, you can load them one by one:

```
Plugin::load('Bootstrap');
Plugin::load('Less');
Plugin::load('BootstrapUI');
```

### Configuration

[](#configuration)

After adding the plugin you can add the desired utilities:

```
// AppController.php
public $helpers = [
    'Less.Less', // required for parsing less files
    'BootstrapUI.Form',
    'BootstrapUI.Html',
    'BootstrapUI.Flash',
    'BootstrapUI.Paginator'
];
```

Or, if loading them in the AppView:

```
// AppView.php
public function initialize()
{
    $this->loadHelper('Less', ['className' => 'Less.Less']);
    $this->loadHelper('Html', ['className' => 'BootstrapUI.Html']);
    $this->loadHelper('Form', ['className' => 'BootstrapUI.Form']);
    $this->loadHelper('Flash', ['className' => 'BootstrapUI.Flash']);
    $this->loadHelper('Paginator', ['className' => 'BootstrapUI.Paginator']);
}
```

Usage
-----

[](#usage)

There are two common usage ways when using twitter bootstrap and less:

- Directly using twitter bootstrap classes on your views.
- Using custom classes on your views and then extending that classes to twitter bootstrap components.

For the first case you can directly [load the layout included](#themes) with this plugin and [bake your views](#baking-views) with the also included bake templates.

For the second case you'll need to [create your own layout](#creating-your-own-layout) and create a stylesheet like the included one `webroot/less/cakephp/styles.less`.

This file extends the default baked views' styles so they have a *CakePHP-Bootstrapped* look and feel.

### Themes

[](#themes)

On both cases you can use the layout included with this plugin as a [theme](http://book.cakephp.org/3.0/en/views/themes.html)(right now there's only the `default` layout):

```
// AppController or AppView
public function beforeRender(\Cake\Event\Event $event)
{
    $this->viewBuilder()->theme('Bootstrap');
}
```

Or as a layout:

```
// AppController or AppView
public $layout = 'Bootstrap.default';
```

You can also specify it as a layout directly from your template files:

```
// any .ctp Template file
$this->layout = 'Bootstrap.default';
```

> You should use the Bootstrap layout if you wanna use `less` files. If you rather preffer using css files you may use the [BootstrapUI](https://github.com/FriendsOfCake/bootstrap-ui/tree/master/src/Template/Layout)layouts.

Last but not least, you can also copy that template to your `Template/Layout`folder and then extend the template from your view.

[Read more about views on the CakePHP Cookbook](http://book.cakephp.org/3.0/en/views.html).

> BTW it's recommended that you copy all the required files to your src folder (specially for assets), even if you won't modify them.

Take in mind that if you're loading this plugin in a fresh CakePHP installation and you try to see the layout change in the home page, you won't see nothing. The `home.ctp` overwrites the layout to `false`, to ensure it's loaded as it has been designed.

### Baking views

[](#baking-views)

You can bake your views using the twitter bootstrap templates bundled with this plugin. To do so, simply specify the `bootstrap` template when baking your files:

```
cake bake.bake [subcommand] --theme Bootstrap
```

Remember that you can also bake your views using [BootstrapUI's bake templates](https://github.com/FriendsOfCake/bootstrap-ui/tree/master/src/Template/Bake). Take a look to its readme for more details.

### Creating your own layout

[](#creating-your-own-layout)

Create a `styles.less` file on your `webroot/less` folder (also create that folder if it does not exist) containing this line:

```
@import '../bootstrap/less/bootstrap.less';
```

Finally, load the less file from your view or layout:

```
echo $this->Less->less('less/styles.less');
```

If you want to extend twitter bootstrap styles I recommend you to copy the `bootstrap.less` file to your `less` folder and customize it to your needs. For the `variables.less` create a `custom-variables.less` and load it just after `variables.less` in `bootstrap.less` file. Any variable defined in that file will overwrite the value defined in `variables.less` and your code won't break when updating (Twitter) Bootstrap.

If you'd like to see an example of this you can check the files included in `webroot/less/cakephp` specially made to extend the default CakePHP baked templates.

Utilities
---------

[](#utilities)

This plugin "includes" the following utilities (all they come from other plugins):

- [Less](https://github.com/elboletaire/less-cake-plugin) [LessHelper](https://github.com/elboletaire/less-cake-plugin#usage)
- [BootstrapUI](https://github.com/FriendsOfCake/bootstrap-ui) [FormHelper](https://github.com/FriendsOfCake/bootstrap-ui#basic-form)
- [BootstrapUI](https://github.com/FriendsOfCake/bootstrap-ui) [HtmlHelper](https://github.com/FriendsOfCake/bootstrap-ui/blob/master/src/View/Helper/HtmlHelper.php)
- [BootstrapUI](https://github.com/FriendsOfCake/bootstrap-ui) [FlashHelper](https://github.com/FriendsOfCake/bootstrap-ui/blob/master/src/View/Helper/FlashHelper.php)
- [BootstrapUI](https://github.com/FriendsOfCake/bootstrap-ui) [PaginatorHelper](https://github.com/FriendsOfCake/bootstrap-ui/blob/master/src/View/Helper/PaginatorHelper.php)

### A note about Bootstrap's FlashComponent

[](#a-note-about-bootstraps-flashcomponent)

The old Bootstrap FlashComponent used to have a `close` option that allowed you to define whether the flash alert would have a close button or not.

With BootstrapUI FlashHelper this works different. It looks for an `alert-dismissible` class (which is set by default) and, if defined, will show the close button.

For disabling the close button for the current Flash alert you can do:

```
$this->Flash->{whatever}("Hello World", ['params' => ['class' => ['alert']]]);

// where {whatever} is any of the Bootstrap alert classes (danger, info, warning...)
$this->Flash->success("Hello World", ['params' => ['class' => ['alert']]]);
```

> Note that the `class` param is defined as an array.

### LessHelper

[](#lesshelper)

Used on your template or view to parse and load the compressed CSS.

The LessHelper is part of the [less cakephp plugin](https://github.com/elboletaire/less-cake-plugin). Check out all its details there.

Dependencies
------------

[](#dependencies)

- [elboletaire/less-cake-plugin](https://github.com/elboletaire/less-cake-plugin) version &gt;= 1.6.1
- [FriendsOfCake/bootstrap-ui](https://github.com/FriendsOfCake/bootstrap-ui) version ~0.3

### Included dependencies

[](#included-dependencies)

- [twbs/bootstrap](https://github.com/twbs/bootstrap): [version 3.3.5 (rev. 94b4076)](https://github.com/twbs/bootstrap/tree/94b4076)

About versioning
----------------

[](#about-versioning)

This project started using the same versioning as CakePHP 3.X during its development stage. For this reason, I'll continue using this but reserving the latest version number for my versions.

This means that any version of this plugin with `3.0.X` version number should be compatible with any CakePHP `3.0` version.

License
-------

[](#license)

```
The MIT License (MIT)

Copyright 2013-2015 Òscar Casajuana (a.k.a. elboletaire)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community14

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~101 days

Recently: every ~170 days

Total

13

Last Release

3394d ago

Major Versions

v2.0.1 → v3.0.0-alpha12014-07-13

PHP version history (2 changes)v2.0.1PHP &gt;=5.3.0

v3.0.0-beta1PHP &gt;=5.4.19

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/153305?v=4)[Òscar Casajuana](/maintainers/elboletaire)[@elboletaire](https://github.com/elboletaire)

---

Top Contributors

[![elboletaire](https://avatars.githubusercontent.com/u/153305?v=4)](https://github.com/elboletaire "elboletaire (107 commits)")

---

Tags

bootstrapcake-plugincakephpcakephp3templatethemeplugincakephptemplatebootstrap

### Embed Badge

![Health badge](/badges/elboletaire-twbs-cake-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/elboletaire-twbs-cake-plugin/health.svg)](https://phpackages.com/packages/elboletaire-twbs-cake-plugin)
```

###  Alternatives

[wyrihaximus/twig-view

Twig powered View for CakePHP

804.7M1](/packages/wyrihaximus-twig-view)[dereuromark/cakephp-ajax

A CakePHP plugin that makes working with AJAX a piece of cake.

55255.9k1](/packages/dereuromark-cakephp-ajax)[backstageel/cakephp-gentelella-theme

CakePHP 3.x Gentelella Theme.

447.8k1](/packages/backstageel-cakephp-gentelella-theme)[dereuromark/cakephp-feed

A CakePHP plugin containing a RssView to generate RSS feeds.

1353.7k1](/packages/dereuromark-cakephp-feed)[dereuromark/cakephp-meta

A CakePHP plugin for SEO meta tags, OpenGraph and Twitter Cards

1012.9k1](/packages/dereuromark-cakephp-meta)

PHPackages © 2026

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