PHPackages                             polyfony-inc/bootstrap - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. polyfony-inc/bootstrap

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

polyfony-inc/bootstrap
======================

Helper to use Bootstrap's HTML elements

2263[1 issues](https://github.com/polyfony-inc/bootstrap/issues)1PHP

Since Jul 3Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/polyfony-inc/bootstrap)[ Packagist](https://packagist.org/packages/polyfony-inc/bootstrap)[ RSS](/packages/polyfony-inc-bootstrap/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (4)Used By (1)

Introduction
============

[](#introduction)

This class helps in building Bootstrap Modals, Dropdowns and Alerts. It currently support Bootstrap 5, other branches may support bootstrap5-alpha or bootstrap 4.

Alert
-----

[](#alert)

- You can use from different types of bootstrap alerts (previously called Notice) to suit your needs

```
Bootstrap\Alert([
	'class'			=>null,
	'message'		=>null,
	'title'			=>null,
	'footer'		=>null,
	'dismissible'	=>true
])
```

All will be converted to HTML automatically using bootstrap 4 friendly classes.

### Typical example using the "flashbag"

[](#typical-example-using-the-flashbag)

```
// set an alert depending on the presence of errors
$foobar->doSomething() ?
	new Bootstrap\Alert([
		'class'=>'danger',
		'message'=>'Cache directory has not been emptied'
	)->save() :
	new Bootstrap\Alert([
		'class'=>'success',
		'message'=>'cache directory has been empties'
	])->save();

// maybe you want to redirect somewhere
Response::setRedirect('/admin/');
```

### Or using shortcuts

[](#or-using-shortcuts)

These will build alerts of class `success` or `danger`. With the Locale *Operation succeeded* or *Operation failed*.

```
use Bootstrap\Alert\{
	Success as OK,
	Failure as KO
};

// [...]

// set an alert depending on the presence of errors
$foobar->doSomething() ? (new OK) : (new KO);

// [...]

// maybe you want to redirect somewhere
Response::setRedirect('/admin/');
```

Then in a shared view, available everywhere

```

```

**You can ask the Logger engine to log your alert by applying -&gt;log() to the alert object.**

- Alert of class danger will map to a Polyfony/Log event of type critical
- Alert of class warning will map to a Polyfony/Log event of type warning
- Any other class will map to a Polyfony/Log event of type info

\### Manually getting back notice text

```
$alert->getMessage()
$alert->getTitle()
$alert->getFooter()
```

Modal
-----

[](#modal)

- generate a modal element

```
echo (new Bootstrap\Modal)
	->setTitle(
		['text'=>'Hey!'],
		'fa fa-car'
	)
	->setBody([
		'text'=>'Here is the content'
	])
	->setTrigger(
		[
			'text'=>'Open the modal',
			'class'=>'btn btn-link'
		],
		'fa fa-send'
	)
	->addOption(
		[
			'text'=>'To this',
			'class'=>'btn btn-success'
		],
		'fa fa-car'
	)
	->addOption(
		[
			'text'=>'To that',
			'class'=>'btn btn-warning'
		],
		'fa fa-car'
	);
```

Dropdown
--------

[](#dropdown)

- generate a dropdown element

```
echo (new Bootstrap\Dropdown)
	->setTrigger(
		[
			'text'=>'Click this nice looking modal',
			'class'=>'btn btn-primary'
		],
		'fa fa-send'
	)
	->addItem([
		'text'=>'To this',
		//'class'=>'some-cool-class'
		//'html'=>'Non protected text'

	])
	->addDivider()
	->addHeader([
		'text'=>'Pretty Header'
	]);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2f1eeb1833c2b47f5f39cc99741055a1075e4c36568803d66f11f2b9ca947c73?d=identicon)[AnnoyingTechnology](/maintainers/AnnoyingTechnology)

---

Top Contributors

[![AnnoyingTechnology](https://avatars.githubusercontent.com/u/5336824?v=4)](https://github.com/AnnoyingTechnology "AnnoyingTechnology (16 commits)")

### Embed Badge

![Health badge](/badges/polyfony-inc-bootstrap/health.svg)

```
[![Health](https://phpackages.com/badges/polyfony-inc-bootstrap/health.svg)](https://phpackages.com/packages/polyfony-inc-bootstrap)
```

PHPackages © 2026

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