PHPackages                             projectsaturnstudios/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. projectsaturnstudios/pocketflow-php

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

projectsaturnstudios/pocketflow-php
===================================

PHP implementation of The-Pocket/PocketFlow

0.1.2(1y ago)18211MITPHPPHP ^8.2

Since Jun 27Pushed 1y agoCompare

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

READMEChangelogDependencies (1)Versions (4)Used By (1)

PocketFlow PHP
==============

[](#pocketflow-php)

> PocketFlow PHP: Minimalist LLM framework for PHP. Let Agents build Agents!

**Language:** PHP | **License:** MIT

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)[![PHP](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)](https://camo.githubusercontent.com/7535257ca228724c93658bd52583d4e47a9bab02c356abf6e54c1d575f2151e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c75652e737667)[![ReactPHP](https://camo.githubusercontent.com/4ff9eb97c15d3bde535c095a54fa8cae614b6ffa3eabaee33b9f45adf759f7f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656163745048502d4f7074696f6e616c2d6f72616e67652e737667)](https://camo.githubusercontent.com/4ff9eb97c15d3bde535c095a54fa8cae614b6ffa3eabaee33b9f45adf759f7f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f52656163745048502d4f7074696f6e616c2d6f72616e67652e737667)[![Total Downloads](https://camo.githubusercontent.com/8f75e071d2907efcef066b2f0835a52c3a9b5378eae571b24fb5d4ec374aed2d/687474703a2f2f706f7365722e707567782e6f72672f70726f6a65637473617475726e73747564696f732f706f636b6574666c6f772d7068702f646f776e6c6f616473)](https://packagist.org/packages/pocketflow-php/downloads)

PocketFlow PHP is the **first PHP implementation** of the [minimalist LLM framework](https://github.com/The-Pocket/PocketFlow) concept

- **Lightweight**: ~400 lines of PHP. Zero bloat, pure PHP elegance.
- **Framework Agnostic**: Works with any PHP project, not tied to specific frameworks.
- **Graph-Based**: Simple node and flow abstraction for complex LLM workflows.
- **ReactPHP Ready**: Optional async support for parallel processing.

Get started with PocketFlow PHP:

- **Installation**: `composer require projectsaturnstudios/pocketflow-php`
- **Quick Start**: Copy the [source files](https://github.com/projectsaturnstudios/pocketflow-php/tree/main/src) into your PHP project
- **Documentation**: Examples in this README and source code
- **LLM Integration**: Bring your own LLM client (OpenAI SDK, Guzzle, etc.)

Why PocketFlow PHP?
-------------------

[](#why-pocketflow-php)

The PHP ecosystem was missing a minimalist LLM workflow framework... until now!

**Abstraction****PHP Integration****LLM Support****Lines****Dependencies**LLPhantComprehensiveFramework agnostic
(Symfony/Laravel compatible)Multiple providers
(OpenAI, Anthropic, Mistral, etc.)~15K+Heavy (many providers)LangChain PHPAgent, ChainBasic
(Work in progress)Limited
(OpenAI, llama.cpp)~5KModerate**PocketFlow PHP****Graph****Framework Agnostic**
(Pure PHP, works anywhere)**Bring Your Own**
(Use any HTTP client)**~400****Minimal**

How does PocketFlow PHP work?
-----------------------------

[](#how-does-pocketflow-php-work)

The core abstraction: **Graph-based workflow execution** with simple nodes and flows.

### Core Components:

[](#core-components)

1. **BaseNode**: Foundation class with `prep()`, `exec()`, `post()` lifecycle
2. **Node**: Extended with retry logic and fallback handling
3. **Flow**: Orchestrates node execution with action-based routing
4. **BatchNode/BatchFlow**: Process arrays of data through workflows
5. **AsyncNode/AsyncFlow**: ReactPHP-powered parallel execution (optional)

### Key Features:

[](#key-features)

- **Reference Passing**: Proper `&$shared` parameter handling for state persistence
- **Type Safety**: Full PHP 8.1+ type declarations
- **Error Handling**: Comprehensive exception handling with fallbacks
- **Memory Management**: Configurable data retention

Examples
--------

[](#examples)

### Basic Hello World

[](#basic-hello-world)

```
