rmunate/php-config-runtime
最新稳定版本:v1.2.0
Composer 安装命令:
composer require rmunate/php-config-runtime
包简介
The PhpRunTime Library provides methods for managing PHP configuration at runtime. It allows you to set, get, and restore configuration options, as well as check their existence and status.
README 文档
README
⚙️ This library is compatible with Laravel versions 8.0 and above ⚙️
The PhpRunTime Library provides methods for managing PHP configuration at runtime. It allows you to set, get, and restore configuration options, as well as check their existence and status.
Table of Contents
Installation
To install the package via Composer, run the following command:
composer require rmunate/php-config-runtime
Available Methods
| Method | Description |
|---|---|
PhpRunTime::set($option, $value) |
Sets the value of a PHP configuration option at runtime using ini_set(). |
PhpRunTime::get($option) |
Gets the current value of a PHP configuration option. If the option is not set or found, returns null. |
PhpRunTime::restore($option) |
Restores a PHP configuration option to its default value. Returns true if the restoration is successful, or false otherwise. |
PhpRunTime::restoreAll() |
Restores all PHP configuration options to their default values. Returns true if all restorations are successful, or false otherwise. |
PhpRunTime::isOptionSet($option) |
Checks if a configuration option is set and has a non-empty value. Returns true if the option is set, or false otherwise. |
PhpRunTime::doesOptionExist($option) |
Checks if a configuration option exists in the php.ini file. Returns true if the option exists, or false otherwise. |
Usage Examples
Set a Configuration Option
use Rmunate\Server\PhpRunTime; // Set the "display_errors" option to "On" PhpRunTime::set('display_errors', 'On'); // Check if the option is set and has a non-empty value if (PhpRunTime::isOptionSet('display_errors')) { // 'The "display_errors" option is enabled.'; } else { // 'The "display_errors" option is not set.'; }
Get the Value of a Configuration Option
use Rmunate\Server\PhpRunTime; // Get the current value of the "max_execution_time" option $maxExecutionTime = PhpRunTime::get('max_execution_time'); if ($maxExecutionTime !== null) { // "The current value of 'max_execution_time' is: $maxExecutionTime seconds."; } else { // "The 'max_execution_time' option is not set."; }
Restore a Configuration Option
use Rmunate\Server\PhpRunTime; // Temporarily set the "memory_limit" option to "256M" PhpRunTime::set('memory_limit', '256M'); // Restore the "memory_limit" option to its default value PhpRunTime::restore('memory_limit'); // Check if the option is set and has a non-empty value if (PhpRunTime::isOptionSet('memory_limit')) { // 'The "memory_limit" option is set.'; } else { // 'The "memory_limit" option is not set.'; }
Restore All Configuration Options
use Rmunate\Server\PhpRunTime; // Temporarily set some configuration options PhpRunTime::set('display_errors', 'On'); PhpRunTime::set('error_reporting', E_ALL); // Restore all options to their default values PhpRunTime::restoreAll(); // Check if the options are set and have non-empty values if (PhpRunTime::isOptionSet('display_errors') || PhpRunTime::isOptionSet('error_reporting')) { // 'Some options could not be restored.'; } else { // 'All options were successfully restored.'; }
Clarifications
-
Changes made using the
set()method are only valid during the execution of the current script and do not affect thephp.inifile. To make permanent changes, it's necessary to manually edit thephp.inifile. -
Some configuration options may be disabled in shared hosting environments, which may limit the ability to change certain configurations.
-
It's important to be cautious when modifying PHP configuration, as some changes can affect the performance and security of applications. It's recommended to consult the official PHP documentation for detailed information on each configuration option.
Creator
- 🇨🇴 Raúl Mauricio Uñate Castro
- Email: raulmauriciounate@gmail.com
License
This project is under the MIT License.
🌟 Support My Projects! 🚀
Make any contributions you see fit; the code is entirely yours. Together, we can do amazing things and improve the world of development. Your support is invaluable. ✨
If you have ideas, suggestions, or just want to collaborate, we are open to everything! Join our community and be part of our journey to success! 🌐👩💻👨💻
rmunate/php-config-runtime 适用场景与选型建议
rmunate/php-config-runtime 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 179 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Agent」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rmunate/php-config-runtime 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rmunate/php-config-runtime 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rmunate/php-config-runtime 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Custom laravel monolog logger for datadog logs management, both api and agent ways
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
Standalone replacement for php's native get_browser() function
A PHP desktop/mobile user agent parser with support for Laravel, based on Mobiledetect
Random user agent generator in PHP.
Alfabank REST API integration
统计信息
- 总下载量: 179
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-24
