ahmedhelalahmed / laravel-greeting
在 Laravel 中以问候消息退出
dev-master
2021-02-10 23:22 UTC
This package is auto-updated.
Last update: 2024-09-11 07:04:13 UTC
README
此包允许在一个输入中执行 die 和 dump。如果没有输入,它将退出并显示默认问候消息“Hello world”。您可以通过在 .env 文件中设置 HELLO_WORLD_MESSAGE 来更改默认消息,也可以将消息记录到日志并清除日志文件。
基本用法
输出简单消息
use AhmedHelalAhmed\LaravelGreeting\Greeting; // It will dump hello world as no input given and default message not changed Greeting::sayMessage();
输出并退出简单消息
use AhmedHelalAhmed\LaravelGreeting\Greeting; // It will dump hello world and stop execution as continue set with false Greeting::sayMessage('hello world',false);
停止并开始发送消息
use AhmedHelalAhmed\LaravelGreeting\Greeting; $x = 10; Greeting::sayMessage([ 'message1' => 'test', 'x' => $x, 'request' => request() ]); // it will show input array like that /* array:3 [▼ "message1" => "test" "x" => 10 "request" => Illuminate\Http\Request { } ] */ // stop sending messages Greeting::stop(); // this has no effect at all Greeting::sayMessage(); // this has no effect as Greeting messages stopped Greeting::sayMessage("Welcome",false); // continue sending messages Greeting::start(); // this will dump the message and die Greeting::sayMessage("Hello world",false);
发送消息并记录到存储文件
use AhmedHelalAhmed\LaravelGreeting\Greeting; // this will dump welcome message and log it to storage file Greeting::sayAndLog('welcome'); // this will log welcome to storage file and dump welcome message then stop execution Greeting::sayAndLog('welcome',false);
清除日志文件
use AhmedHelalAhmed\LaravelGreeting\Greeting; // this will clear the content of log file Greeting::resetLog(); // you can install // https://github.com/rap2hpoutre/laravel-log-viewer // to view logs
安装
您可以通过 composer 安装此包
composer require --dev ahmedhelalahmed/laravel-greeting
然后发布配置
php artisan vendor:publish --provider="AhmedHelalAhmed\LaravelGreeting\LaravelGreetingServiceProvider"
贡献
感谢您考虑为 ahmedhelalahmed/laravel-greeting 做出贡献。
安全
如果您在 ahmedhelalahmed/laravel-greeting 中发现安全漏洞,请通过 ahmed.helal.online@gmail.com 发送电子邮件给 Ahmed Helal。所有安全漏洞都将得到及时处理。
鸣谢
许可证
ahmedhelalahmed/laravel-greeting 是开源软件,采用 MIT 许可证。