PHPackages                             siarko/cli-bootstrap - 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. [CLI &amp; Console](/categories/cli)
4. /
5. siarko/cli-bootstrap

ActiveLibrary[CLI &amp; Console](/categories/cli)

siarko/cli-bootstrap
====================

PHP Cli bootstrap library. Implements error handling, main cli loop

0.1.4(3mo ago)07PHP

Since Apr 12Pushed 3mo agoCompare

[ Source](https://github.com/Siarko/cli-bootstrap)[ Packagist](https://packagist.org/packages/siarko/cli-bootstrap)[ RSS](/packages/siarko-cli-bootstrap/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (6)Used By (0)

What is this
============

[](#what-is-this)

This is a simple library that implements methods usefull in creating console applications.

Features
--------

[](#features)

- Maintaining constant TPS (Ticks Per Second)
- Running code in loop, multiple tasks can be defined
- Events emmited on:
    - Initialization complete
    - OS Signals received
    - Cleanup started (Exiting, but before error logs are collected)
    - Exit (Last moment to execute any code)

Example
-------

[](#example)

```
// This is a dependency Event manager, or any that implements interface
$eventManager = new EventManager();
// Logger is also a part of this lib; but very basic
$logger = new BasicLogger(__DIR__.'/logs.log');

$bootstrap = new Bootstrap($eventManager, $logger);

// Set how much times to execute tasks per second
$bootstrap->setTargetTPS(2);

/** @var $event SignalEvent */
$eventManager->addListener(function(SignalEvent $event) use($bootstrap){
    // CTRL + C -> We should stop running
    if($event->getData() === SIGINT) {
        echo "[INTERRUPT]\n";
        // This is how we stop
        $bootstrap->stop();
    }
});

$eventManager->addListener(function(CleanupEvent $event) {
    // This will be called almost always
    echo "[CLEANUP EVENT]\n";
});

$eventManager->addListener(function(ExitEvent $event) {
    // This will be called almost always - last event before exiting
    echo "[EXIT EVENT]\n";
});

$bootstrap->addTask(function () use ($bootstrap){
    // Just to slow down the logs
    usleep(200000);
    echo "ITERATION\n";
    echo $bootstrap->getLoopTime().", TPS: ". $bootstrap->getCurrentTPS()."\n";
});

// Start loop execution. Will block until loop is stopped
// Either with $bootstrap->stop(), with error or however else.
$bootstrap->run();
```

### Extending / Development

[](#extending--development)

This repo ships with docker compose configuration to ease development. Build container: `.docker/build.sh`Start container: `.docker/run.sh`

Dockerfile already has a `XDEBUG_TRIGGER=1` flag, so all executions should work with xdebug OOTB. As a basic example, there's a `cli.php` script that I used for testing in `dev` directory.

### AI

[](#ai)

No AI was used for creation of this code.

###  Health Score

31

—

LowBetter than 65% of packages

Maintenance80

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity28

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.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

103d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13398512?v=4)[Mateusz](/maintainers/siarko)[@Siarko](https://github.com/Siarko)

---

Top Contributors

[![Siarko](https://avatars.githubusercontent.com/u/13398512?v=4)](https://github.com/Siarko "Siarko (6 commits)")

### Embed Badge

![Health badge](/badges/siarko-cli-bootstrap/health.svg)

```
[![Health](https://phpackages.com/badges/siarko-cli-bootstrap/health.svg)](https://phpackages.com/packages/siarko-cli-bootstrap)
```

###  Alternatives

[symfony/cache

Provides extended PSR-6, PSR-16 (and tags) implementations

4.2k373.5M3.4k](/packages/symfony-cache)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[league/climate

PHP's best friend for the terminal. CLImate allows you to easily output colored text, special formats, and more.

1.9k14.7M304](/packages/league-climate)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k16](/packages/tempest-framework)[api-platform/metadata

API Resource-oriented metadata attributes and factories

295.0M223](/packages/api-platform-metadata)[mimmi20/browser-detector

Library to detect Browsers and Devices

48157.6k5](/packages/mimmi20-browser-detector)

PHPackages © 2026

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