PHPackages                             ahmard/preact - 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. ahmard/preact

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

ahmard/preact
=============

Performs action before-hand, confirms action execution.

1.0.3(5y ago)164MITPHPPHP &gt;=5.4.0

Since Oct 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Ahmard/preact)[ Packagist](https://packagist.org/packages/ahmard/preact)[ RSS](/packages/ahmard-preact/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (4)Dependencies (1)Versions (5)Used By (0)

Preact
======

[](#preact)

Performs action before-hand, confirms action execution.
This program uses [ReactPHP Promise](https://github.com/reactphp/promise) for its promise implementation.

Installation
------------

[](#installation)

```
composer require ahmard/preact
```

Usage
-----

[](#usage)

1. [Event](#event)
2. [Preact](#preact)

Event
-----

[](#event)

An event system for simple event-driven programming.

```
use Preact\Event;

$event = new Event();

$event->on('user.created', function ($user){
    echo "User created: {$user['name']}";
});

$user = [
    'id' => 1,
    'name' => 'Admin'
];
$event->emit('user.created', [$user]);
```

You can use **Preact\\EventTrait** trait directly in your class and have the functionality embedded in your code.

```
namespace App\User;

use Preact\EventTrait;

class User
{
    use EventTrait;

    public function create(array $userInfo)
    {
        //Save in DB
        $this->emit('created', [$userInfo]);
    }
}

$user = new User;

$user->on('created', function ($user){
    echo "User created: {$user['username']}\n";
});

$user->create([
    'username' => 'Admin',
    'email' => 'admin@test.local'
]);
```

Preact
------

[](#preact-1)

Have confirmation before execution.

```
use React\Promise\PromisorInterface;
use Preact\PreactTrait;

class Animal
{
    use PreactTrait;
}

$animal = new Animal();

$animal->onPreact('can.create', function (PromisorInterface $promisor, $animalInfo){
    if($animalInfo['name'] == 'lion'){
        $promisor->resolve(true);
    }else{
        $promisor->reject(false);
    }
});

$animal->preact('can.create', ['lion'])
    ->then(function (){
        echo 'Animal creation allowed: lion';
    })
    ->otherwise(function (){
        echo 'Animal creation rejected: lion.\n';
    });
```

To see more use cases view [examples](/examples).

Licence
-------

[](#licence)

**Preact** is MIT licenced.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Every ~1 days

Total

4

Last Release

2033d ago

### Community

Maintainers

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

---

Top Contributors

[![Ahmard](https://avatars.githubusercontent.com/u/44737217?v=4)](https://github.com/Ahmard "Ahmard (1 commits)")

### Embed Badge

![Health badge](/badges/ahmard-preact/health.svg)

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

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[react/react

ReactPHP: Event-driven, non-blocking I/O with PHP.

9.1k3.6M63](/packages/react-react)[reactivex/rxphp

Reactive extensions for php.

1.7k3.2M49](/packages/reactivex-rxphp)[internal/dload

Downloads binaries.

98142.7k10](/packages/internal-dload)[wyrihaximus/react-child-process-messenger

Messenger decorator for react/child-process

32279.4k4](/packages/wyrihaximus-react-child-process-messenger)[wyrihaximus/react-cron

⏱️ Cronlike scheduler running inside the ReactPHP Event Loop

4050.6k](/packages/wyrihaximus-react-cron)

PHPackages © 2026

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