PHPackages                             manhdoan91/traits - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. manhdoan91/traits

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

manhdoan91/traits
=================

Useful PHP traits.

0227PHP

Since Mar 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/manhdoan91/traits)[ Packagist](https://packagist.org/packages/manhdoan91/traits)[ RSS](/packages/manhdoan91-traits/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

### manhdoan91 - PHP Traits v1.0.0

[](#manhdoan91---php-traits-v100)

---

Collection of some useful traits what I use across my packages but can be useful to any1 (who knows right?).

#### RunTimeCache trait

[](#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

[](#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

[](#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();
}
```

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a9a7f977ec1af32e9c83b8d57f7e897c6e8b5f614bd5f90c478b77ecca0187a?d=identicon)[manhdoan91](/maintainers/manhdoan91)

---

Top Contributors

[![manhdoan91](https://avatars.githubusercontent.com/u/43535450?v=4)](https://github.com/manhdoan91 "manhdoan91 (7 commits)")

### Embed Badge

![Health badge](/badges/manhdoan91-traits/health.svg)

```
[![Health](https://phpackages.com/badges/manhdoan91-traits/health.svg)](https://phpackages.com/packages/manhdoan91-traits)
```

###  Alternatives

[formapro/pvm

The library provides us with a frame to build a workflow or a business process such as BPMN. Could execute tasks in parallel or delayed tasks

36823.8k](/packages/formapro-pvm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
