palmtree / bootstrap-alerts
Bootstrap alerts
Installs: 1 019
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=8.1
Requires (Dev)
This package is auto-updated.
Last update: 2024-12-06 17:25:27 UTC
README
Bootstrap alert manager for PHP projects.
Add and display bootstrap alerts with relevant Font Awesome icons
Requirements
- PHP >= 8.1
Installation
Use composer to add the package to your dependencies:
composer require palmtree/bootstrap-alerts
Usage
Echoing the AlertManager class will invoke __toString()
on each alert and return a concatenated string of HTML.
<?php $alertManager = new \Palmtree\BootstrapAlerts\AlertManager(); $alertManager->addSuccess('It worked!'); $alertManager->addInfo('Did you know?'); $alertManager->addWarning('Make sure you did it right'); $alertManager->addError('Something went wrong!'); echo $alertManager;
You can also filter alerts:
<?php $alertManager = new \Palmtree\BootstrapAlerts\AlertManager(); $alertManager->addWarning('Make sure you did it right'); $alertManager->addError('Something went wrong!'); $alertManager->addError('Another thing went wrong!'); foreach($alertManager->getAlerts('error') as $errorAlert) { echo $errorAlert; }
License
Released under the MIT license