PHPackages                             chatflowphp/core - 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. chatflowphp/core

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

chatflowphp/core
================

Platform-neutral conversational flow core for PHP.

1.0.0(today)001MITPHPPHP ^8.2CI passing

Since Jun 22Pushed todayCompare

[ Source](https://github.com/chatflowphp/core)[ Packagist](https://packagist.org/packages/chatflowphp/core)[ Docs](https://github.com/chatflowphp/core)[ RSS](/packages/chatflowphp-core/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (10)Versions (2)Used By (1)

ChatFlow Core
=============

[](#chatflow-core)

[![CI](https://github.com/chatflowphp/core/actions/workflows/ci.yml/badge.svg)](https://github.com/chatflowphp/core/actions/workflows/ci.yml)[![PHPStan](https://camo.githubusercontent.com/b6d441ad4fe8332cb16c72aa27f22cc685181dfd74ae34964afc92c6c1146b3c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c2532306d61782d627269676874677265656e2e737667)](https://phpstan.org/)[![PHPUnit](https://camo.githubusercontent.com/bc004f75aacf2d6c71f73022452e7825ae8b775a86bc7c9826a7d07e5ab02279/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850556e69742d7465737465642d627269676874677265656e2e737667)](https://phpunit.de/)[![License: MIT](https://camo.githubusercontent.com/08cef40a9105b6526ca22088bc514fbfdbc9aac1ddbf8d4e6c750e3a88a44dca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d626c75652e737667)](LICENSE)

`chatflowphp/core` is the platform-neutral runtime for chat workflows.

It contains routing, middleware, scenes/FSM, sessions, validation, normalized inbound events and platform-neutral outgoing views. It does not depend on Telegram or any other transport SDK.

Full package documentation starts at [docs/index.md](docs/index.md). Use [docs/ai-index.md](docs/ai-index.md) as compact context for AI-assisted flow implementation tasks.

Using This Through `chatflowphp/telegram`?
------------------------------------------

[](#using-this-through-chatflowphptelegram)

If you are building a Telegram bot, keep `chatflowphp/telegram` as the main onboarding surface.

Read only this subset from core unless you are extending the runtime itself:

1. [Context](docs/context.md)
2. [Routing](docs/routing.md)
3. [Views And Effects](docs/views-effects.md)
4. [Scenes](docs/scenes.md)
5. [Storage](docs/storage.md)
6. [Validation](docs/validation.md)
7. [Testing](docs/testing.md)

`Architecture`, `Application Runtime` and adapter internals are optional for normal product bot development.

Runtime Model
-------------

[](#runtime-model)

Adapters convert platform input into `InboundEvent` with typed refs:

- `ConversationRef` is the stable session key.
- `UserRef` identifies the actor when the platform provides one.
- `MessageRef` carries platform delivery metadata for the adapter.
- `InboundAttachment` represents incoming files/media.

Handlers use `Context`:

```
$ctx->getConversationId();
$ctx->getUserId();
$ctx->getText();
$ctx->getActionId();
$ctx->reply('Hello');
$ctx->render(View::text('Updated'));
$ctx->ack('Saved');
```

`reply()`, `render()` and `ack()` enqueue outbound effects. `Application` flushes those effects through the platform adapter after the handler, middleware and scene lifecycle complete.

Shared Flow Contract
--------------------

[](#shared-flow-contract)

Reusable business flows implement `FlowInterface` and register against `FlowRuntimeInterface`. Adapter facades implement that runtime contract, so portable flow code can be reused when the product semantics are truly the same. Public adapter examples should still be platform-native because every chat platform has different UX and delivery constraints.

Routing
-------

[](#routing)

Core routes are platform-neutral:

```
$application->onCommand('start', $handler);
$application->onTextPrefix('/search', $handler);
$application->onTextRegex('/^ticket:\d+$/', $handler);
$application->onAction('support:open', $handler);
$application->onActionPrefix('support:', $handler);
$application->onActionRegex('/^scene:/', $handler);
$application->fallback($handler);
```

First registered route wins.

Adapter Contract
----------------

[](#adapter-contract)

Adapters implement `PlatformAdapterInterface`:

- `createInboundEvent()` normalizes platform input.
- `deliver()` sends `ReplyEffect`, `RenderEffect` and `AckEffect`.
- `downloadAttachment()` handles synchronous file download where supported.
- `capabilities()` declares platform support for actions, choices, media, render, ack and attachment download.

Core enforces capabilities before queuing unsupported effects.

Observability
-------------

[](#observability)

Pass a `RuntimeObserverInterface` to `Application` to receive lifecycle events:

- `inbound.received`
- `route.matched`
- `route.missing`
- `scene.matched`
- `scene.entered`
- `effect.queued`
- `effect.delivered`
- `delivery.failed`
- `handler.failed`

Adapters may expose this through their facade constructors.

For local development, `JsonlRuntimeObserver` writes those events as newline-delimited JSON:

```
use ChatFlow\Observability\JsonlRuntimeObserver;

$observer = new JsonlRuntimeObserver(__DIR__ . '/storage/runtime.jsonl');
```

Session TTL
-----------

[](#session-ttl)

`StateManager` accepts an optional `sessionTtlSeconds` value. Expired sessions are deleted from storage and recreated on load.

Serialization Rules
-------------------

[](#serialization-rules)

Action payloads, metadata and session state must contain only scalar values, `null`, arrays of allowed values or `BackedEnum`. Non-backed `UnitEnum`, objects and resources are rejected.

License
-------

[](#license)

This project is released under the MIT License. See `LICENSE` for details.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4216840?v=4)[webnarmin](/maintainers/webnarmin)[@webnarmin](https://github.com/webnarmin)

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/chatflowphp-core/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

562565.8k42](/packages/ecotone-ecotone)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

749284.3k35](/packages/civicrm-civicrm-core)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

40159.2k19](/packages/rareloop-lumberjack-core)

PHPackages © 2026

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