palmtree / bootstrap-alerts
Bootstrap 警报
v2.0.0
2023-09-13 08:49 UTC
Requires
- php: >=8.1
Requires (Dev)
README
为 PHP 项目提供 Bootstrap 警报管理器。
添加并显示与相关 Bootstrap 警报 和 Font Awesome 图标
需求
- PHP >= 8.1
安装
使用 composer 将包添加到依赖项
composer require palmtree/bootstrap-alerts
使用方法
输出 AlertManager 类将触发每个警报的 __toString()
方法,并返回一个拼接的 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;
您还可以筛选警报
<?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; }
许可协议
在 MIT 许可协议 下发布