deanblackborough / bootstrap-4-helpers
Standalone Bootstrap 4 view helpers to use outside of Zend Framework apps
Installs: 32
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/deanblackborough/bootstrap-4-helpers
Requires
Suggests
- php: ^7.2
This package is auto-updated.
Last update: 2025-10-07 05:26:44 UTC
README
Bootstrap 4 helpers
Bootstrap 4 component helpers
Description
Utility wrapper classes for the Bootstrap 4 view helpers in my ZF3-view-helpers library (https://github.com/deanblackborough/zf3-view-helpers), allows usage of the view helpers in any PHP site, not just Zend Framework apps.
Installation
The easiest way to use the view helpers is via composer, composer require deanblackborough/bootstrap-4-helpers,
alternatively include the classes in src/ in your library.
Usage
Create a view helper is a two step process, you need to call the ViewHelper factory to create the relevant view helper and then you can chain the helpers methods to create your component.
$jumbotron = ViewHelper::jumbotron('Heading', '<p>Content</p>');
echo $jumbotron->fluid()->setBgStyle('primary');
The view helpers
Alert
Factory call
$alert = ViewHelper::alert('Alert message');
Methods, can be chained
setBgStyle(string $color)- Set the background coloursetHeading(string $heading, int $heading_level)- Set optional headingsetTextStyle(string $color)- Set the text colour
Badge
Factory call
$badge = ViewHelper::badge('Label');
Methods, can be chained
asLink()- As linkpill()- Display as pillsetBgStyle(string $color)- Set the background coloursetTextStyle(string $color)- Set the text colour
Button
Factory call
$button = ViewHelper::button('Label');
Methods, can be chained
active()- Activeblock()- Display as a full width blockcustomClass(string $class)- Add a custom classdisabled()- Set disabledlarge()- Large buttonsetBgStyle(string $color)- Set the background coloursetModeButton()- Render as a buttonsetModeInput()- Render as an inputsetOutlineStyle()- Outline buttonsetUri(string $uri)- Set URIsmall()- Small button
Column
Factory call
$column = ViewHelper::column('<p>Content</p>');
Methods, can be chained
lg(int $size)- Set lg column widthmd(int $size)- Set md column widthsetBgStyle(string $color)- Set the background coloursetTextStyle(string $color)- Set the text coloursm(int $size)- Set sm column widthxl(int $size)- Set xl column widthxs(int $size)- Set xs column width
Jumbotron
Factory call
$jumbotron = ViewHelper::jumbotron('Heading', '<p>Content</p>');
Methods, can be chained
fluid()- Add fluid classsetBgStyle(string $color)- Set the background coloursetHeadingDisplayLevel(int $level)- Set the display levelsetSubHeading(string $sub_heading)- Set an optional sub headingsetTextStyle(string $color)- Set the text colour
Progress bar
Factory call
$progressBar = ViewHelper::progressBar(25);
Methods, can be chained
animate()- AnimatesetBgStyle(string $color)- Set the background coloursetHeight(int $height)- Set heightsetLabel(string $label)- Set a labelsetTextStyle(string $color)- Set the text colourstriped()- Striped background
Row
Factory call
$row = ViewHelper::row('<div class="col-6"></div>');
Methods, can be chained
setBgStyle(string $color)- Set the background coloursetTextStyle(string $color)- Set the text colour
No tests?
I'm not adding tests to this library, the tests for the functionality are within the https://github.com/deanblackborough/zf3-view-helpers library, this library simply makes it possible to use the view helpers outside of the Zend Framework, I've not added any additional functionality.