marcha/lumen-opcache

Laravel 和 Lumen 的 PHP OPcache 艺术命令。

1.0.0 2020-12-19 21:58 UTC

This package is auto-updated.

Last update: 2024-09-20 06:39:45 UTC


README

Latest Version on Packagist Software License Total Downloads

此包包含一些有用的 Artisan 命令,用于与 PHP OPcache 一起工作。

如果您想了解更多关于 OPcache 以及它可以为您的 Laravel 应用程序做什么,请阅读 Medium 上的文章:让您的 Laravel 应用程序借助 PHP OPcache 飞起来

要求

此包需要 Laravel 7 或更高版本。

安装

您可以通过 Composer 安装此包

composer require Marcha/laravel-opcache

在您的 bootstrap/app.php 文件中添加以下行以注册提供者

$app->register(Marcha\Opcache\OpcacheServiceProvider::class);

如果您需要更改配置值,您可以使用以下命令发布配置文件

php artisan vendor:publish --provider="Marcha\Opcache\OpcacheServiceProvider" --tag="config"

确保您的 APP_URL 在 .env 文件中设置正确。

如果您想设置一个不同的 URL 来调用 OPcache 路由(例如,用于负载均衡器),您可以设置 OPCACHE_URL。

用法

清除 OPcache

php artisan opcache:clear

显示 OPcache 配置

php artisan opcache:config

显示 OPcache 状态

php artisan opcache:status

预编译您的应用程序代码

php artisan opcache:compile {--force}

注意:必须启用 opcache.dups_fix ,或者使用 --force 标志。如果您遇到 "Cannot redeclare class" 错误,请启用 opcache.dups_fix 或将类路径添加到排除列表中。

程序化使用

use Marcha\Opcache\OpcacheFacade as OPcache;

...

OPcache::clear();

致谢

此包最初是从 appstract/laravel-opcache 分支出来的。

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅许可证文件