mwstake/mediawiki-component-dynamicconfig
Composer 安装命令:
composer require mwstake/mediawiki-component-dynamicconfig
包简介
Dynamic config manager
README 文档
README
This component is designed to store configuration variables in Database and load (and apply) them from there.
It is primarely meant to replace config directory in BlueSpiceFoundation and configs stored in actual static PHP files.
It can be used to store any number of configurations, basically everything that goes into LocalSettings.php, except for
core configs, like DB connection and similar.
Compatibility
2.0.x-> MediaWiki 1.431.0.x-> MediaWiki 1.39
Registering configs
- Implement a class that implements
MWStake\MediaWiki\Component\DynamicConfig\IDynamicConfiginterface. - Use
MWStakeDynamicConfigRegisterConfigsHook to register your configs.
In case your config sets/reads MW globals ($GLOBALS), make it implement
MWStake\MediaWiki\Component\DynamicConfig\GlobalsAwareDynamicConfig interface as well.
Using configs
To store config to DB, use
$manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' ); $manager->storeConfig( $config, $dataToBePassedToTheConfig );
This will call serialize method on the IDynamicConfig object with $dataToBePassedToTheConfig as an argument.
This method must return a string to be stored to the Database.
If your config's shouldAutoApply method returns true, the config will be auto-applied on SetupAfterCache hook.
Otherwise, you can apply it manually by calling
$manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' ); $manager->applyConfig( $config );
When applying, method apply will be called on the IDynamicConfig object with the data from the Database as an argument.
Config itself is responsible for parsing the data and applying it.
Backups
On every change of a config value, a backup will be made. System will create up to 5 backups, after which it will rotate, deleting the oldest one.
Restoring backups
From code
$manager = \MediaWiki\MediaWikiServices::getInstance()->getService( 'MWStakeDynamicConfigManager' ); $manager->restoreBackup( $config, $dataTime ); // DateTime object matching the timestamp of available backup
From CLI
# List available config types php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --list-types # List avilable backups for a type php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --list-backups --config={key} # Restore a backup (timestamp in YmdHis format) php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php --backup-timestamp=20230523104627 --config={key}
Note: This will assume component is installed in the root vendor directory. If its not, specify path to Maintenance.php, as the first
argument of the script.
# List available config types
php vendor/mwstake/mediawiki-component-dynamicconfig/maintenance/restoreFromBackup.php some/path/Maintenance.php --list-types
mwstake/mediawiki-component-dynamicconfig 适用场景与选型建议
mwstake/mediawiki-component-dynamicconfig 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 05 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mwstake/mediawiki-component-dynamicconfig 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mwstake/mediawiki-component-dynamicconfig 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2023-05-25