manhdoan91/traits
Composer 安装命令:
composer require manhdoan91/traits
包简介
Useful PHP traits.
README 文档
README
manhdoan91 - PHP Traits v1.0.0
Collection of some useful traits what I use across my packages but can be useful to any1 (who knows right?).
RunTimeCache trait
Simple runtime cache for results or objects. The traits reserves the $runTimeCache variable.
// Check if the key stored in the cache. $object->runTimeCacheExists('my.last.result.for.X'); // Store a value in the cache by key. $object->runTimeCacheSet('my.last.result.for.X', [1,2,3]); // Get the value from the cache by key. $object->runTimeCacheGet('my.last.result.for.Y', ['Fallback', 'value', 'if not found']); // Delete a value from the cache. $object->runTimeCacheDelete('resultX'); // Import a cache array, replace all existing value. $object->runTimeCacheImport(['r1' => 2, 'r3' => 94]); // Export the cache array. $object->runTimeCacheExport(); // Erase the cache values. $object->runTimeCacheReset();
ObjetConfig trait
Store configuration on an object. The trait reserves the $objectConfig variable.
// Check key in the config. $object->objectConfigExists('cache_key'); // Set a value in the config. $object->objectConfigSet('cache_key', 'hoc'); // Get a value from the config. $object->objectConfigGet('cache_key', 'fallback_value'); // Delete a configuration by key from the object. $object->objectConfigDelete('cache_key'); // Import a config array. $object->objectConfigImport($myNewConfig); // Export the config array. $object->objectConfigExport(); // Reset the config. $object->objectConfigReset();
PluginCollection trait
Register and deregister plugins to an object. The trait reserves the $pluginCollection variable.
// Import plugins in PLUGIN => CONFIG setup. $object->pluginCollectionImport([ 'plugins\GoogleSearch' => ['secret_key' => 42], 'plugins\FacebookSearch' => ['secret_key' => 43], ]); // Export the collection. $object->pluginCollectionExport(); // Register a new plugin to the collection. $object->pluginCollectionRegister('plugins\AOL', ['secret_key' => 42]); // Deregister a plugin by it's key. $object->pluginCollectionDeregister('plugins\FacebookSearch'); // Check if a plugin is registered by it's key. $object->pluginCollectionIsRegistered('plugins\FacebookSearch'); // Practical useage. $this->pluginCollectionRegister('plugins\Bing', ['secret_key' => 95]); foreach($this->pluginCollectionExport() as $plugin => $config) { $pluginInstance = new $plugin; $pluginInstance->objectConfigImport($config); $plugin->searchOrWhatEver(); }
manhdoan91/traits 适用场景与选型建议
manhdoan91/traits 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 265 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 03 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「traits」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 manhdoan91/traits 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 manhdoan91/traits 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 manhdoan91/traits 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Model mapping, unmapping and validation
Various traits related to xWP packages
Various traits related to xWP packages
A trait for Laravel models which have many users with roles.
Traits gathering fluent syntax common methods
Common tools used in Obsidian Moon projects
统计信息
- 总下载量: 265
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 7
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-25