承接 elmyrockers/ezflash 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. First of all, you can install via composer:

    composer require elmyrockers/ezflash
  2. Add the following line into your PHP code:

    require_once 'vendor/autoload.php'; //Load Composer's autoloader
    use elmyrockers\EzFlash;
  3. Create new instance of EzFlash class:

    $message = new EzFlash;
  4. 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
  5. 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>
  6. 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

Simple Tutorial

Authors

@elmyrockers

License

MIT

统计信息

  • 总下载量: 39
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-06-08