承接 naotty/laravel-pr-message 相关项目开发

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

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

naotty/laravel-pr-message

最新稳定版本:1.0.2

Composer 安装命令:

composer require naotty/laravel-pr-message

包简介

Laravel middleware to add PR message to API response headers

README 文档

README

Laravel middleware to add PR message to API response headers.
You can enter the message you want to convey to the user!

Installation

Install using Composer:

composer require naotty/laravel-pr-message

Configuration

Publish the configuration file

Run the following command to publish the configuration file:

php artisan vendor:publish --tag=pr-message-config

This will create the config/pr-message.php file.

Customize the messages

Edit the config/pr-message.php file to customize the PR messages:

return [
    'messages' => [
        'Would you like to work with us? We are hiring engineers!',
        'This service makes you happy!',
        'Let\'s create better services together!',
        'This service makes your life better!',
        'You, who are reading this message, would you like to work with us?',
        // Add your own messages
    ],
];

Usage

Response Headers

When using this middleware, the following HTTP header will be added to your API responses:

  • pr-message: A randomly selected message from your configured message list

Register as a global middleware

Add the following to the $middleware array in the app/Http/Kernel.php file:

protected $middleware = [
    // Other middleware
    \Naotty\LaravelPrMessage\Middleware\AddPrMessageHeader::class,
];

Apply to a specific route

Use the alias that is already registered in the $routeMiddleware array in the app/Http/Kernel.php file:

protected $routeMiddleware = [
    // Other middleware
    'pr-message' => \Naotty\LaravelPrMessage\Middleware\AddPrMessageHeader::class,
];

Then, use it in the route definition:

Route::get('/api/endpoint', function () {
    return response()->json(['data' => 'example']);
})->middleware('pr-message');

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-05-09