elmyrockers/ezflash
最新稳定版本:1.0.1
Composer 安装命令:
composer require elmyrockers/ezflash
包简介
EzFlash PHP library - Lightweight, simple and easy way to display flash message with Bootstrap 5 (Alert) template
README 文档
README
Lightweight, simple and easy way to display flash message with Bootstrap 5 (Alert) template
Usage/Examples
-
First of all, you can install via composer:
composer require elmyrockers/ezflash
-
Add the following line into your PHP code:
require_once 'vendor/autoload.php'; //Load Composer's autoloader use elmyrockers\EzFlash;
-
Create new instance of EzFlash class:
$message = new EzFlash;
-
After that, you can set flash message in 4 different ways:
$message->{$key} = {$yourmessage};
$message->success = 'Message'; //Property $message['success'] = 'Message'; //Array key $message->success( 'Message' ); //Method call or $message( 'success', 'Message' ); //Function call
-
Then, that flash message can be displayed using echo:
echo $message(); //Function call with no parameter
Or you can treat this object like a string:
echo $message;
For instance, if you write code like the following statement:
$message( 'success', 'My message' ); //Set flash message through function call echo $message; // Echo flash message (one-time display)
Then, its output will look like this one:
<div class="alert alert-success">My message</div>
-
You can set different template for each $key:
$message->setTemplate( ['success', 'danger', 'warning', 'info', 'primary', 'secondary', 'light', 'dark', 'default'], '<div class="alert alert-{$key}">{$message}</div>' ); //default //custom template $message->setTemplate( 'errorInfo', '<div class="alert alert-danger {$key}">{$message}</div>' );
You can override default/existing template too with this.
Reference
Authors
License
统计信息
- 总下载量: 39
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-08