PHPackages                             stolfam/utils-php8 - 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. stolfam/utils-php8

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

stolfam/utils-php8
==================

PHP classes which may help and save your time.

5.0.5(2y ago)0353MITPHPPHP &gt;= 8.2

Since May 23Pushed 2y ago1 watchersCompare

[ Source](https://github.com/stolfam/utils-php8)[ Packagist](https://packagist.org/packages/stolfam/utils-php8)[ RSS](/packages/stolfam-utils-php8/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (3)Versions (2)Used By (3)

PHP 8 Utils
===========

[](#php-8-utils)

Bunch of helpful classes, interfaces, traits.

- **E-mail** (gives you domain of email)
- Person, **Name** (automatically separates first and last name)
- Comparator + interface Comparable
- Sorter (using our Comparable interface)
- Messenger, Message
- Pair, Array
- cached data storage (useful for complex repositories)
- interface Databaseable
- simple Cron (queue of definable tasks)

Using
-----

[](#using)

This is an introduction of some features included in this bundle.

### Databaseable

[](#databaseable)

This interface is useful for preparing data for saving into a database.

```
class DatabaseEntity implements Databaseable {

    /** @var int */
    protected $id;

    public function row(): array {
        return [
            "id" => $this->$id
        ];
    }
}

```

### Cached Data Storage

[](#cached-data-storage)

If you want to speed up your system, a cache is probably one of the way which you may choose. Using is very easy. Look at the example below.

#### Example

[](#example)

```
// your object
$object = new SerializableObject();

// init our data storage
$cache = new DataStorage(__DIR__ . "/../tmp");

// init unique key of your object for our storage
$key = new Key($object->id, "some_prefix_of_your_repository");

// save/replace data
$cache->add($key, $object);

// load data
$objectFromCache = $cache->get($key);

// and if your data have changed, just call 'notifyChange', it will be erase object from cache
$cache->notifyChange($key);

```

**Hint:** It is very useful in complex repositories, when some data depend on other data and you are able to speed up whole system, because you load only changed data.

### Dependency

[](#dependency)

That is very useful for multi-level caching of data structures. For example: Imagine that you have a data object called X compounded from smaller data objects A, B and C coming from different resources. For a better speed of a system it is good to use cache for each small object A, B and C and to create dependency between these small objects and the big one X, which would be in the cache as well. This will cause that if change any of the small objects - only that object would be need to reload. After it, the big one will be created from two small from the cache and third (now reloaded) also from cache. At the end the big one X will be stored in the cache as well again until any of the smaller objects will change.

#### Example

[](#example-1)

```
// defining dependencies with IKey
$cache->createDependency($childKey, $parentKey);
$cache->createDependency($parentKey, $grandParentKey);

// automatic update of parent and grandparent when child changed
$cache->notifyChange($childKey)

```

Because of a child changed, all dependent data (a child, a parent and a grandparent) have become invalid and will be overridden with a newer version of data.

### Cron

[](#cron)

This is a very simple `class` for creating a queue of tasks. You can basically create only one file `run.php` with tasks definition and execute only that.

#### Example

[](#example-2)

```
// OPTIONAL
// when you plan to use time-based tasks, you have to set a folder for persist files
Clock::setDataPath( __DIR__ . "/persistData/clocks" );

// creating a Cron
$cron = new Cron();

// class MyTask implements interface ITask or extends abstract class TimedTask
$cron->addTask( new MyTask() );
$cron->addTask( ... );

// executing
$cron->run();

// feedback
foreach ($cron->messenger as $message) {
    echo $message->type . ": " . $message->text;
}

```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

771d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a166fb0b766fa1febb53e4dcee9075a1350e7438e623cd7baafbd8e40557fb9?d=identicon)[stolfam](/maintainers/stolfam)

---

Top Contributors

[![stolfam](https://avatars.githubusercontent.com/u/37073073?v=4)](https://github.com/stolfam "stolfam (2 commits)")

### Embed Badge

![Health badge](/badges/stolfam-utils-php8/health.svg)

```
[![Health](https://phpackages.com/badges/stolfam-utils-php8/health.svg)](https://phpackages.com/packages/stolfam-utils-php8)
```

###  Alternatives

[nette/php-generator

🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 8.5 features.

2.3k72.7M763](/packages/nette-php-generator)[nette/component-model

⚛ Nette Component Model

28817.0M106](/packages/nette-component-model)[pragmarx/countries

PHP Countries and Currencies

1.9k3.4M24](/packages/pragmarx-countries)[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5275.9M121](/packages/symplify-monorepo-builder)[nette/code-checker

✅ Nette CodeChecker: A simple tool to check source code against a set of Nette coding standards.

911.7M6](/packages/nette-code-checker)[shipmonk/input-mapper

Performant array-to-object mapper supporting generics, array shapes, optional fields and much more!

3030.9k](/packages/shipmonk-input-mapper)

PHPackages © 2026

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