PHPackages                             weise25/pocketflow-php - 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. weise25/pocketflow-php

ActiveLibrary[Framework](/categories/framework)

weise25/pocketflow-php
======================

A PHP port of the minimalist LLM framework PocketFlow.

v0.2.0(2mo ago)8172[1 PRs](https://github.com/weise25/PocketFlow-PHP/pulls)MITPHPPHP &gt;=8.3

Since Jul 31Pushed 2mo agoCompare

[ Source](https://github.com/weise25/PocketFlow-PHP)[ Packagist](https://packagist.org/packages/weise25/pocketflow-php)[ RSS](/packages/weise25-pocketflow-php/feed)WikiDiscussions main Synced today

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

PocketFlow-PHP
==============

[](#pocketflow-php)

[![PocketFlow-PHP Logo](assets/logo.png)](assets/logo.png)

**A minimalist LLM framework for PHP, inspired by the 100-line Python original.**

Build complex Agents, Workflows, RAG systems and more, with a tiny, powerful core.

 [![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://github.com/weise25/PocketFlow-PHP/blob/main/LICENSE) [![PHP 8.3+](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)](#) [![Async with ReactPHP](https://camo.githubusercontent.com/9fc29e4a0275e81e1209f2d6c6315e64b1e1e3baa1a4720bc966807c784297d9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4173796e632d52656163745048502d626c756576696f6c6574)](https://packagist.org/packages/react/async)

---

**PocketFlow-PHP** is a port of the amazing 100-line Python framework [PocketFlow](https://github.com/The-Pocket/PocketFlow) from [Zachary](https://github.com/zachary62/), bringing its core principles to the PHP ecosystem. It's built for **Agentic Coding** — you design the system, an AI agent writes the code.

- **Lightweight**: ~700 lines of clean PHP across 14 PSR-4 files.
- **Expressive**: Multi-Agent systems, RAG pipelines, Workflows, Map-Reduce — all from simple composable building blocks.
- **Agentic-Coding Ready**: Ships with an Agent Skill (`.agents/skills/pocketflow-php/`) that makes any AI coding tool instantly fluent in the framework.

How does it work?
-----------------

[](#how-does-it-work)

The core abstraction is a **Graph + Shared Store**:

1. **Node**: Smallest unit of work — `prep()` → `exec()` → `post()`, with built-in retry/fallback.
2. **Flow**: Connects Nodes into a directed graph. String "Actions" determine transitions.
3. **Shared Store**: A `SharedStore` object passed through the entire flow for inter-node communication.

From these three primitives you build every design pattern: Agent, Workflow, RAG, Map-Reduce, Multi-Agent, and more.

Quick Start
-----------

[](#quick-start)

Build your own app in 60 seconds using the [Template](https://github.com/weise25/pocketflow-php-template):

```
git clone https://github.com/weise25/pocketflow-php-template.git my-app

cd my-app

composer install
```

Open in any AI coding tool that supports the [Agent Skills](https://agentskills.io) standard — **Cline**, **Cursor**, **Windsurf**, **Claude Code**, **OpenCode**, and others. The built-in skill automatically teaches your agent the framework.

Then just describe what you want to build:

> *"Build me a research agent that searches the web and synthesizes a report."*

The agent will write `nodes.php`, `flow.php`, `main.php`, and `utils/` — following the 8-step Agentic Coding process.

Installing in an Existing Project
---------------------------------

[](#installing-in-an-existing-project)

```
composer require weise25/pocketflow-php
```

```
use  PocketFlow\Node;

use  PocketFlow\Flow;

use  PocketFlow\SharedStore;

// etc.
```

Examples
--------

[](#examples)

ExamplePatternDescription[Web Search Agent](examples/web-search-agent)AgentMulti-step research with Brave Search + OpenRouter[Multi Agent Quiz Show](examples/quiz-show-multi-agent)Multi-AgentThree AI agents — a host and two contestants — play a quiz game[Simple Text-to-CV](examples/text-to-cv-with-frontend)Workflow + FrontendGenerate a CV plan, iterate with edits, output PDF[Text2SQL REPL](examples/text2sql)Workflow / AgentPopulate a DB, chat with your Database in natural languageUpgrading from 0.1.x
--------------------

[](#upgrading-from-01x)

Version 0.2.0 introduced these breaking changes:

1. **Replace `stdClass` with `SharedStore`**: All `run()`, `prep()`, `post()` etc. now expect `PocketFlow\SharedStore` instead of `stdClass`. Change `new stdClass()` to `new SharedStore()` and update type hints.
2. **Async methods renamed**: `run_async()` → `runAsync()`, `prep_async()` → `prepAsync()`, `exec_async()` → `execAsync()`, `post_async()` → `postAsync()`, `exec_fallback_async()` → `execFallbackAsync()`.
3. **Exception handling**: The framework now throws `LogicException` or `RuntimeException` instead of issuing `E_USER_WARNING`.
4. **Namespaces**: All classes now live in the `PocketFlow\` namespace. Add `use PocketFlow\Node;` etc. to your files.
5. **PSR-4 structure**: Classes are now one-per-file instead of a single `PocketFlow.php`.

Why This Approach?
------------------

[](#why-this-approach)

PocketFlow-PHP doesn't try to be a massive framework with every feature built in. It provides the graph abstraction, the retry mechanism, and the async backbone — then gets out of your way. Utility functions (LLM calls, web search, embedding) are yours to write or swap. This keeps the core tiny, portable, and vendor-agnostic.

Paired with an AI coding agent, the framework's strict structure eliminates common LLM errors and lets the agent focus on translating your intent into code — at dramatic speed.

**Ready to build? Clone the template and start creating.**

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance88

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.1% 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 ~272 days

Total

2

Last Release

65d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/209492988?v=4)[Djamal Weise](/maintainers/weise25)[@weise25](https://github.com/weise25)

---

Top Contributors

[![weise25](https://avatars.githubusercontent.com/u/209492988?v=4)](https://github.com/weise25 "weise25 (35 commits)")[![weised30](https://avatars.githubusercontent.com/u/205667303?v=4)](https://github.com/weised30 "weised30 (2 commits)")[![google-labs-jules[bot]](https://avatars.githubusercontent.com/in/842251?v=4)](https://github.com/google-labs-jules[bot] "google-labs-jules[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/weise25-pocketflow-php/health.svg)

```
[![Health](https://phpackages.com/badges/weise25-pocketflow-php/health.svg)](https://phpackages.com/packages/weise25-pocketflow-php)
```

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.2k341.0k1](/packages/ccxt-ccxt)[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.5k196.2M3.1k](/packages/composer-composer)[laravel/reverb

Laravel Reverb provides a real-time WebSocket communication backend for Laravel applications.

1.6k15.1M84](/packages/laravel-reverb)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k420.9k26](/packages/team-reflex-discord-php)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[internal/dload

Downloads binaries.

102212.2k19](/packages/internal-dload)

PHPackages © 2026

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