PHPackages                             sflightning/bundle - 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. [Framework](/categories/framework)
4. /
5. sflightning/bundle

ActiveSymfony-bundle[Framework](/categories/framework)

sflightning/bundle
==================

Symfony bundle that add support for Swoole trough Lightning library

014PHP

Since Oct 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/BaptisteContreras/lightning-bundle)[ Packagist](https://packagist.org/packages/sflightning/bundle)[ RSS](/packages/sflightning-bundle/feed)WikiDiscussions main Synced 5d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Lightning Symfony Bundle
========================

[](#lightning-symfony-bundle)

A bundle for [Symfony](https://symfony.com/) applications using [Swoole](https://www.swoole.co.uk/).

This bundle provides a bridge to use [Swoole](https://www.swoole.co.uk/) with Symfony and it tries to simplify the use of Swoole concurrency.

This bundle comes with its own [Runtime](https://github.com/BaptisteContreras/lightning-runtime), [Contracts](https://github.com/BaptisteContreras/lightning-contracts) and [Implementation](https://github.com/BaptisteContreras/lightning-lib)

This project is inspired by the excellent [Laravel Octane](https://github.com/laravel/octane) and try to provide a good alternative for Symfony applications !

**Still in development**

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

[](#installation)

```
 composer require sflightning/bundle

```

Usage
-----

[](#usage)

This bundle comes with it's own Promise definition : `Sflightning\Contracts\Concurrency\Promise\LightningPromiseInterface` and implementation : `Sflightning\Lib\Concurrency\Promise` .

#### Create a Promise

[](#create-a-promise)

You can create a Promise with it's constructor or using the static builder `buildFromCallable`. In both cases you need to provide a `callable` which represents the task to be executed concurrently.

```

use Sflightning\Lib\Concurrency\Promise\Promise;

$promise = new Promise(function(callable $resolve, callable $reject) {
      // Your async task here;
});

$promise->then(function ($result) {
     // If your task succeed;
});

$promise->catch(function ($result) {
    // If your task gone wrong;
});

$promise->finally(function () {
   // And in any case;
});

```

Or you can also use the static builder

```
$promise = Promise::buildFromCallable(function(callable $resolve, callable $reject) {
            // Your async task here;
        })->then(function ($result) {
                // If your task succeed;
        })->catch(function ($result) {
            // If your task gone wrong;
        })->finally(function () {
            // And in any case;
        });

```

#### Execute your promises asynchronously

[](#execute-your-promises-asynchronously)

Now that you have created your promises, it's time to execute them ! (And concurrently). For that, it's simple : You just have to implement `Sflightning\Bundle\Concurrency\LightningConcurrencyAware`and use the trait `Sflightning\Bundle\Concurrency\LightningConcurrency`. Now your object has three new methods available:

- **executePromise(LightningPromiseInterface $promise): void** : Execute the given promise asynchronously. This method is non-blocking.
- **executePromises(...$promises): void** : Execute the given promises asynchronously. This method is non-blocking.
- **waitForPromise(LightningPromiseInterface $promise, int $timeout = Concurrency::PROMISE\_WAIT\_INFINITELY): void** : Wait for the given promise to finish. This is the only blocking method in this trait !

```
class MyAsyncService implements LightningConcurrencyAware
{
    use LightningConcurrency;

    public function doSmth(...$args): void
    {
        $promise = Promise::buildFromCallable(function(callable $resolve, callable $reject) {
            // Your async task here;
        })->then(function ($result) {
            // If your task succeed;
        })->catch(function ($result) {
            // If your task gone wrong;
        })->finally(function () {
            // And in any case;
        });

        $this->executePromise($promise);

        // More code

        $this->waitForPromise($promise);
    }
}

```

You can also start a promise in a service and wait for it in the calling controller's method:

```
// MyAsyncService.php

class MyAsyncService implements LightningConcurrencyAware
{
    use LightningConcurrency;

    public function doSmth(LightningPromiseInterface $promise): void
    {
        // Your code

        $this->executePromise($promise);

        // More code

        // Notice that we don't do any waitForPromise here, it's the calling object duty for this example !
    }
}

// TestController.php

class TestController implements LightningConcurrencyAware
{
    use LightningConcurrency;

    public function method1(Request $request, MyAsyncService $myAsyncServiceInstance): void
    {
        $promise = Promise::buildFromCallable(function(callable $resolve, callable $reject) {
            // Your async task here;
        });

        $myAsyncServiceInstance->doSmth($promise);

        $this->waitForPromise($promise);

        return new Response('OK', 200);
    }
}

```

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity24

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/29d32f0de7bf0abd199486576ed2251e0b40d1f4312330f74c842a226a244947?d=identicon)[BaptisteContreras](/maintainers/BaptisteContreras)

---

Top Contributors

[![BaptisteContreras](https://avatars.githubusercontent.com/u/38988658?v=4)](https://github.com/BaptisteContreras "BaptisteContreras (7 commits)")

### Embed Badge

![Health badge](/badges/sflightning-bundle/health.svg)

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

###  Alternatives

[laravel/telescope

An elegant debug assistant for the Laravel framework.

5.2k67.8M192](/packages/laravel-telescope)[spiral/roadrunner

RoadRunner: High-performance PHP application server and process manager written in Go and powered with plugins

8.4k12.2M84](/packages/spiral-roadrunner)[nolimits4web/swiper

Most modern mobile touch slider and framework with hardware accelerated transitions

41.8k177.2k1](/packages/nolimits4web-swiper)[laravel/dusk

Laravel Dusk provides simple end-to-end testing and browser automation.

1.9k36.7M259](/packages/laravel-dusk)[laravel/prompts

Add beautiful and user-friendly forms to your command-line applications.

708181.8M596](/packages/laravel-prompts)[cakephp/chronos

A simple API extension for DateTime.

1.4k47.7M121](/packages/cakephp-chronos)

PHPackages © 2026

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