PHPackages                             distantmagic/resonance - 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. distantmagic/resonance

ActiveLibrary[Framework](/categories/framework)

distantmagic/resonance
======================

PHP Framework with AI capabilities.

v0.31.0(1y ago)228291↓100%141MITPHPPHP &gt;=8.2

Since Oct 24Pushed 1y ago9 watchersCompare

[ Source](https://github.com/distantmagic/resonance)[ Packagist](https://packagist.org/packages/distantmagic/resonance)[ RSS](/packages/distantmagic-resonance/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (47)Versions (53)Used By (1)

Resonance
=========

[](#resonance)

About Resonance
---------------

[](#about-resonance)

Resonance is designed from the ground up to facilitate interoperability and messaging between services in your infrastructure and beyond. It provides AI capabilities, has a built in web server and integrates with [llama.cpp](https://github.com/ggerganov/llama.cpp).

Takes full advantage of asynchronous PHP. Built on top of Swoole.

Why Resonance?
--------------

[](#why-resonance)

### Predictable Performance

[](#predictable-performance)

Resonance is designed with a few priorities: no memory leaks, blocking operations, and garbage collector surprises.

Most of the internals are read-only and stateless. After the application startup, nothing disturbs JIT and opcode (Reflection is only used during the application startup), so there are no surprise slowdowns during runtime.

### Opinionated

[](#opinionated)

All the libraries under the hood have been thoroughly tested to ensure they work together correctly, complement each other, and work perfectly under async environments.

For example, Resonance implements custom [Doctrine](https://www.doctrine-project.org/) drivers, so it uses Swoole's connection pools.

### Resolves Input/Output Issues

[](#resolves-inputoutput-issues)

Resonance is designed to handle IO-intensive tasks, such as serving Machine Learning models, handling WebSocket connections, and processing long-running HTTP requests.

It views modern applications as a mix of services that communicate with each other asynchronously, including AI completions and ML inferences, so it provides a set of tools to make this communication as easy as possible.

### Complete Package

[](#complete-package)

Resonance includes everything you need to build a modern web application, from the HTTP server to the AI capabilities.

It provides security features, HTML templating, integration with open-source LLMs, and provides capability to serve ML models.

Documentation
-------------

[](#documentation)

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

[](#installation)

It's best to install Resonance by using Composer's create-project command:

```
composer create-project distantmagic/resonance-project my-project
```

Resonance requires minimum 8.2 version of PHP, as well as Data Structures and Swoole extensions. Read more about required and recommended extensions, as well as other installation methods in our [installation guide](https://resonance.distantmagic.com/docs/getting-started/installation-and-requirements.html).

### First-time use

[](#first-time-use)

You'll need to create a `config.ini` file after installing the project (`config.ini.example` is provided) and then use `bin/resonance.php` as an entry point.

### Running the server

[](#running-the-server)

`php bin/resonance.php` serve starts the built-in HTTP server. If you need to, you can generate the [SSL Certificate for Local Development](https://resonance.distantmagic.com/docs/extras/ssl-certificate-for-local-development/).

Features
--------

[](#features)

### Chat with Open-Source LLMs

[](#chat-with-open-source-llms)

Create prompt controllers to directly answer user's prompts.

LLM takes care of determining user's intention, you can focus on taking an appropriate action.

```
#[RespondsToPromptSubject(
    action: 'adopt',
    subject: 'cat',
)]
#[Singleton(collection: SingletonCollection::PromptSubjectResponder)]
readonly class CatAdopt implements PromptSubjectResponderInterface
{
    public function respondToPromptSubject(PromptSubjectRequest $request, PromptSubjectResponse $response): void
    {
        // Pipes message through WebSocket...

        $response->write("Here you go:\n\n");
        $response->write("   |\_._/|\n");
        $response->write("   | o o |\n");
        $response->write("   (  T  )\n");
        $response->write("  .^`-^-`^.\n");
        $response->write("  `.  ;  .`\n");
        $response->write("  | | | | |\n");
        $response->write(" ((_((|))_))\n");
        $response->end();
    }
}
```

### Asynchronous Where it Matters

[](#asynchronous-where-it-matters)

Respond asynchronously to incoming RPC or WebSocket messages (or both combined) with little overhead.

You can set up all the asynchronous features using attributes. No elaborate configuration is needed.

```
#[RespondsToWebSocketJsonRPC(JsonRPCMethod::Echo)]
#[Singleton(collection: SingletonCollection::WebSocketJsonRPCResponder)]
final readonly class EchoResponder extends WebSocketJsonJsonRPCResponder
{
    public function getConstraint(): Constraint
    {
        return new StringConstraint();
    }

    public function onRequest(
        WebSocketAuthResolution $webSocketAuthResolution,
        WebSocketConnection $webSocketConnection,
        RPCRequest $rpcRequest,
    ): void {
        $webSocketConnection->push(new JsonRPCResponse(
            $rpcRequest,
            $rpcRequest->payload,
        ));
    }
}
```

### Simple Things Remain Simple

[](#simple-things-remain-simple)

Writing HTTP controllers is similar to how it's done in the synchronous code.

Controllers have new exciting features that take advantage of the asynchronous environment.

```
#[RespondsToHttp(
    method: RequestMethod::GET,
    pattern: '/',
)]
function Homepage(ServerRequestInterface $request, ResponseInterface $response): TwigTemplate
{
    return new TwigTemplate('website/homepage.twig');
}
```

### Consistency is Key

[](#consistency-is-key)

You can keep the same approach to writing software no matter the size of your project.

There are no growing central configuration files or service dependencies registries. Every relation between code modules is local to those modules.

```
#[ListensTo(HttpServerStarted::class)]
#[Singleton(collection: SingletonCollection::EventListener)]
final readonly class InitializeErrorReporting extends EventListener
{
    public function handle(object $event): void
    {
        // ...
    }
}
```

### Promises in PHP

[](#promises-in-php)

Resonance provides a partial implementation of Promise/A+ spec to handle various asynchronous tasks.

```
$future1 = new SwooleFuture(function (int $value) {
    assert($value === 1);

    return $value + 2;
});

$future2 = $future1->then(new SwooleFuture(function (int $value) {
    assert($value === 3);

    return $value + 4;
}));

assert($future2->resolve(1)->result === 7);
```

### GraphQL Out of the Box

[](#graphql-out-of-the-box)

You can build elaborate GraphQL schemas by using just the PHP attributes.

Resonance takes care of reusing SQL queries and optimizing the resources' usage.

All fields can be resolved asynchronously.

```
#[GraphQLRootField(
    name: 'blogPosts',
    type: GraphQLRootFieldType::Query,
)]
#[Singleton(collection: SingletonCollection::GraphQLRootField)]
final readonly class Blog implements GraphQLFieldableInterface
{
    public function __construct(
        private DatabaseConnectionPoolRepository $connectionPool,
        private BlogPostType $blogPostType,
    ) {}

    public function resolve(): GraphQLReusableDatabaseQueryInterface
    {
        return new SelectBlogPosts($this->connectionPool);
    }

    public function toGraphQLField(): array
    {
        return [
            'type' => new ListOfType($this->blogPostType),
            'resolve' => $this->resolve(...),
        ];
    }
}
```

Tutorials
---------

[](#tutorials)

- ['Hello, World' with Resonance](https://resonance.distantmagic.com/tutorials/hello-world/)
- [Session-Based Authentication](https://resonance.distantmagic.com/tutorials/session-based-authentication/)
- [Building a Basic GraphQL Schema](https://resonance.distantmagic.com/tutorials/basic-graphql-schema/)
- [How to Serve LLM Completions (With llama.cpp)?](https://resonance.distantmagic.com/tutorials/how-to-serve-llm-completions/)
- [How to Create LLM WebSocket Chat with llama.cpp?](https://resonance.distantmagic.com/tutorials/how-to-create-llm-websocket-chat-with-llama-cpp/)
- [Semi-Scripted Conversational Applications](https://resonance.distantmagic.com/tutorials/semi-scripted-conversational-applications/)

Community
---------

[](#community)

Feel free to use [GitHub discussions](https://github.com/distantmagic/resonance/discussions) and other pages related to the repository.

License
-------

[](#license)

The Resonance framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

39

↑

LowBetter than 87% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.9% 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 ~5 days

Recently: every ~26 days

Total

50

Last Release

622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a90b03a697d3734da2112cdd496a854a0b96055006c0d8121afc9f0e5f131c2f?d=identicon)[mcharytoniuk](/maintainers/mcharytoniuk)

---

Top Contributors

[![mcharytoniuk](https://avatars.githubusercontent.com/u/1286785?v=4)](https://github.com/mcharytoniuk "mcharytoniuk (571 commits)")[![david-d-h](https://avatars.githubusercontent.com/u/75451291?v=4)](https://github.com/david-d-h "david-d-h (7 commits)")[![malzag](https://avatars.githubusercontent.com/u/12105347?v=4)](https://github.com/malzag "malzag (4 commits)")[![gurachek](https://avatars.githubusercontent.com/u/36629170?v=4)](https://github.com/gurachek "gurachek (1 commits)")

---

Tags

aiframeworkllamacppllmphpswoole

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/distantmagic-resonance/health.svg)

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

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.5M599](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.1k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M127](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k14.6k](/packages/prestashop-prestashop)[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.7k3.6M355](/packages/pimcore-pimcore)

PHPackages © 2026

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