richardstyles/laravel-vapor-support
Composer 安装命令:
composer require richardstyles/laravel-vapor-support
包简介
Adds additional support for Laravel vapor applications
README 文档
README
Laravel Vapor Support
A small support package to help large Vapor applications which may occasionally hit "Internal Server Error" due to large request sizes.
This package provides a middleware to monitor the main response:
- Illuminate\Http\Response
- Illuminate\Http\JsonResponse
- Symfony\Component\HttpFoundation\BinaryFileResponse
There is also support for:
- Symfony\Component\HttpFoundation\StreamedResponse
However, because a streamed response length is generally unknown, by default a 'info' level log is recorded to aid debugging.
This package provides a middleware which can be used to monitor the length of the response body. This allows you to be notified if a page is starting to exceed the Vapor/AWS limits. The default logs included allow for route name (if set), url and size to be logged to help you pinpoint any pages of concern.
Installation
You can install the package via composer:
composer require richardstyles/laravel-vapor-support
You can publish the config file with:
php artisan vendor:publish --tag="laravel-vapor-support-config"
This is the contents of the published config file:
return [ 'warning_size' => env('VAPOR_SUPPORT_RESPONSE_WARNING_SIZE', 5000000), 'warning_action' => \RichardStyles\LaravelVaporSupport\Actions\ResponseSizeWarning::class, 'limit_size' => env('VAPOR_SUPPORT_RESPONSE_LIMIT_SIZE', 6000000), 'limit_action' => \RichardStyles\LaravelVaporSupport\Actions\ResponseSizeLimit::class, 'stream_action' => \RichardStyles\LaravelVaporSupport\Actions\StreamResponseMonitor::class, ];
Usage
Simply add the middleware to either the Kernal.
app/Http/Kernel.php
protected $middlewareGroups = [ 'web' => [ ... \RichardStyles\LaravelVaporSupport\Http\Middleware\ResponseLimitMonitor::class, ], ...
Or as a named middleware to use on individual routes.
protected $routeMiddleware = [ ... 'response.monitor' => \RichardStyles\LaravelVaporSupport\Http\Middleware\ResponseLimitMonitor::class, ];
For monitoring response sizes (in bytes), these can be set in your .ENV, or by modifying the config.
Examples set very low
VAPOR_SUPPORT_RESPONSE_WARNING_SIZE=1000 VAPOR_SUPPORT_RESPONSE_LIMIT_SIZE=5000
Using the example above would cause;
- The Warning class run when response body exceeds "1000" bytes.
- The Limit class runs when response body exceeds "5000" bytes.
The config also allows the base classes to be overridden. The Limit and Warning classes must implement RichardStyles\LaravelVaporSupport\Contracts\HandlesResponsesLimit
The stream response should implement RichardStyles\LaravelVaporSupport\Contracts\HandlesStreamResponse as with streamed responses you cannot easily know it's length.
The default actions taken by this package is to Log either:
- Log info on streamed response
- Log warning when request length exceeds
warning_size - Log critical when request length exceeds
limit_size
By implementing your own classes and setting these within the config vapor-support you can notify/alert
however your application requires, such as to Bugsnag or other third party services.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Support
If you are having general issues with this package, feel free to contact me on Twitter.
If you believe you have found an issue, please report it using the GitHub issue tracker, or better yet, fork the repository and submit a pull request with a failing test.
If you're using this package, I'd love to hear your thoughts. Thanks!
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
richardstyles/laravel-vapor-support 适用场景与选型建议
richardstyles/laravel-vapor-support 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5 次下载、GitHub Stars 达 5, 最近一次更新时间为 2022 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「richardstyles」 「laravel vapor」 「laravel-vapor-support」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 richardstyles/laravel-vapor-support 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 richardstyles/laravel-vapor-support 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 richardstyles/laravel-vapor-support 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Build a dynamic list of trusted proxies for use with Laravel Vapor
This package can log incoming requests to the cloud watch for laravel vapor application.
Allow Eloquent attributes to be encrypted and decrypted using a RSA 4096-bit private keys.
An artisan command to assist deploying your Laravel Vapor app to multiple AWS regions
Simple plugin to make it easier to run Winter CMS on Laravel Vapor
Alfabank REST API integration
统计信息
- 总下载量: 5
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-22