PHPackages                             sohris/events - 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. sohris/events

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

sohris/events
=============

0.5.1(1y ago)0224MITPHP

Since Dec 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sohris/events)[ Packagist](https://packagist.org/packages/sohris/events)[ RSS](/packages/sohris-events/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (25)Used By (0)

Sohris Events
=============

[](#sohris-events)

The `sohris/events` library is a PHP package designed to facilitate the creation and management of asynchronous and parallel events. By leveraging annotations, developers can efficiently schedule and control task execution within their applications.

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

[](#installation)

To install the `sohris/events` package, use Composer:

```
composer require sohris/events
```

Ensure that your project meets the following requirements:

- PHP 7.4 or higher
- `ext-parallel` extension
- `doctrine/annotations` version ^1.13
- `mtdowling/cron-expression` version ^1.2
- `sohris/core` version ^0.5

Usage
-----

[](#usage)

After installation, you can create events using annotations to define their scheduling and behavior.

Available Annotations
---------------------

[](#available-annotations)

The `sohris/events` library provides annotations to configure events. The primary annotations include:

- `@StartRunning`: Indicates that the event should automatically execute when the server starts.
- `@Time`: Sets the event's execution frequency. It can be of type `Interval` (interval in seconds) or `Cron` (using crontab syntax).

**Usage Example:**

```
/**
 * @Time(
 *     type="Cron",
 *     time="00 00 * * *"  // Executes daily at midnight
 * )
 * @StartRunning
 */
```

Implementation Example
----------------------

[](#implementation-example)

Below is an example of an event class utilizing the provided annotations:

```
