audunru / memory-usage
记录Laravel中的内存使用情况
v2.0.2
2024-08-25 08:17 UTC
Requires
- php: ^8.2
- laravel/framework: ^11.0
- spatie/laravel-package-tools: ^1.9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- orchestra/testbench: ^9.0
- php-coveralls/php-coveralls: ^2.2
- phpmd/phpmd: ^2.10
- phpunit/phpunit: ^11.0
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-09-25 08:34:01 UTC
README
记录HTTP请求期间的内存使用量。峰值内存使用量(以兆字节为单位)将在响应返回前记录。
内存限制可以按请求路径配置。如果您将限制设置为所有请求的25 MiB,您将在日志中看到如下内容:
[2022-01-16 10:49:17] local.WARNING: Maximum memory 50.68 MiB used during request for /api/v1/companies/1/products is greater than limit of 25.00 MiB
[2022-01-16 10:49:29] local.WARNING: Maximum memory 50.39 MiB used during request for /api/v1/companies/1 is greater than limit of 25.00 MiB
[2022-01-16 10:49:29] local.WARNING: Maximum memory 60.04 MiB used during request for /api/v1/companies/1/sales is greater than limit of 25.00 MiB
自v0.3.0起,您还可以记录缓慢的响应。如果您将限制设置为3秒,您将在日志中看到如下内容:
[2022-01-16 10:49:17] local.WARNING: Response time 5.15 s for /api/v1/companies/1/products is greater than limit of 3.00 s
安装
步骤1:使用Composer安装
composer require audunru/memory-usage
配置
通过运行以下命令发布配置文件:
php artisan vendor:publish --tag=memory-usage-config
请打开配置文件,获取有关如何配置日志的进一步说明。
开发
测试
运行测试
composer test