PHPackages                             alancole/atomic - 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. alancole/atomic

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

alancole/atomic
===============

A php eventing/scheduling library.

1.0.1(9y ago)222

Since Mar 22Compare

[ Source](https://github.com/waxim/Atomic)[ Packagist](https://packagist.org/packages/alancole/atomic)[ RSS](/packages/alancole-atomic/feed)WikiDiscussions Synced 2d ago

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

[![StyleCI](https://camo.githubusercontent.com/22f9c62067d362c137bf8f0843361e0e34a3d5525589683e2644d7d18b6c58db/68747470733a2f2f7374796c6563692e696f2f7265706f732f38353833393935392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/85839959) [![Build Status](https://camo.githubusercontent.com/236a396923bf37734fb0a8c4a5b5d5cddc9b3905137df8d6612a452c3c7357da/68747470733a2f2f7472617669732d63692e6f72672f776178696d2f41746f6d69632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/waxim/Atomic)

Atomic
======

[](#atomic)

Atomic is a PHP schedule library, events can be build and scheduled. You may use Atomic simply to schedule your events, or you can attach an adapter and use our bin provided to run your jobs based on a cron schedule.

Schedule a job
--------------

[](#schedule-a-job)

```
# Schedule an event on the first of december each year.
$yearly = new Atomic\Schedule\Yearly(new DateTime("1st December"));

$event = new Atomic\Event("dec-log-clear", $yearly, function() {
    Logs::clearAll(); // hypothetical event code.
});

# Some check at a later time
if ($event->isDue()) {
    $event->fire();
}
```

Stacks
------

[](#stacks)

If you like you can register all your events no a stack and have the stack fire any events as they are due.

```
$stack = new Atomic\Event\Stack([$event, $event2, $event3]);
$evnt = $stack->getNextEvent();

if ($evnt) {
    Log::info("Triggering event " . $evnt->getName());
    $result = $evnt->fire();
    Log::info("Event Return: " . $result);
}
```

If you dont need to care about extra event data besides its return value you can just ask the stack to trigger the events for you, if it finds an event it will run it, if not it will return false.

```
$return = $stack->trigger();
if ($return) {
    Log::info("Oh, we fired an event. It returned: " . $return);
} else {
    Log::info("No events found.");
}
```

Mappers
-------

[](#mappers)

We provide a simple mapper, which will take an array of events return a stack. This is handy if you store events in a database table and you want to load that into a stack.

```
try {
    $mapper = new Atomic\Event\Mapper($events, [
        'name'      => 'name',
        'schedule'  => 'schedule',
        'callback'  => 'callback',
        'first_run' => 'start_time'
    ]);

    $stack = $mapper->getStack();
    $stack->trigger();

} catch (Exception $e) {
    Log::warn($e->getMessage());
}
```

Custom Schedules
----------------

[](#custom-schedules)

You can add your own schedules quite simply by using the `ScheduleInterface` your schedule must accept a datetime on construct and it must return a true or false on `isNow` if this function returns true a stack will fire this event.

This class would trigger your function Every Wednesday.

```
namespace Custom\Schedule;

class EveryWednesday implements \Atomic\Schedule\ScheduleInterface
{
    public function __construct(DateTime $time = null)
    {
        return true;
    }

    public function getName()
    {
        return "Every Wednesday";
    }

    public function getNextRun()
    {
        return new DateTime("Wednesday");
    }

    public function getFirstRun()
    {
        return new DateTime("Wednesday");
    }

    public function isNow(DateTime $time = null)
    {
        return date("D") == "Wed";
    }
}
```

Install
-------

[](#install)

```
composer require waxim/atomic

```

Test
----

[](#test)

```
phpunit

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity65

Established project with proven stability

 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 ~0 days

Total

2

Last Release

3388d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6cee12237f7ad937cba998c0a4745f87986389a414a529309c0ab15095801d20?d=identicon)[alancole](/maintainers/alancole)

---

Top Contributors

[![waxim](https://avatars.githubusercontent.com/u/3833567?v=4)](https://github.com/waxim "waxim (10 commits)")

### Embed Badge

![Health badge](/badges/alancole-atomic/health.svg)

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

###  Alternatives

[mkusher/padawan

Smart php completion server

2577.2k](/packages/mkusher-padawan)

PHPackages © 2026

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