Download the PHP package projectsaturnstudios/pocketflow-php without Composer
On this page you can find all versions of the php package projectsaturnstudios/pocketflow-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download projectsaturnstudios/pocketflow-php
More information about projectsaturnstudios/pocketflow-php
Files in projectsaturnstudios/pocketflow-php
Package pocketflow-php
Short Description PHP implementation of The-Pocket/PocketFlow
License MIT
Informations about the package pocketflow-php
PocketFlow PHP
PocketFlow PHP: Minimalist LLM framework for PHP. Let Agents build Agents!
Language: PHP | License: MIT
PocketFlow PHP is the first PHP implementation of the minimalist LLM framework 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 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?
The PHP ecosystem was missing a minimalist LLM workflow framework... until now!
(Symfony/Laravel compatible) | Multiple providers
(OpenAI, Anthropic, Mistral, etc.) | ~15K+ | Heavy (many providers) | | LangChain PHP | Agent, Chain | Basic
(Work in progress) | Limited
(OpenAI, llama.cpp) | ~5K | Moderate | | **PocketFlow PHP** | **Graph** | **Framework Agnostic**
(Pure PHP, works anywhere) | **Bring Your Own**
(Use any HTTP client) | **~400** | **Minimal** |
How does PocketFlow PHP work?
The core abstraction: Graph-based workflow execution with simple nodes and flows.
Core Components:
- BaseNode: Foundation class with
prep()
,exec()
,post()
lifecycle - Node: Extended with retry logic and fallback handling
- Flow: Orchestrates node execution with action-based routing
- BatchNode/BatchFlow: Process arrays of data through workflows
- AsyncNode/AsyncFlow: ReactPHP-powered parallel execution (optional)
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
Basic Hello World
LLM Integration Example
Self-Looping Chat Bot
Advanced Patterns
Batch Processing
Async Workflows (ReactPHP - Optional Dependency)
Conditional Routing
Comparison with Original PocketFlow
Feature | Python PocketFlow | PHP PocketFlow | Notes |
---|---|---|---|
Core Abstraction | ✅ Graph | ✅ Graph | Same philosophy |
Async Support | ✅ asyncio | ⚠️ ReactPHP (optional) | Different implementations |
Framework Integration | ❌ None | ✅ Framework Agnostic | Works with any PHP project |
LLM Providers | ❌ Manual | ❌ Bring Your Own | Both require manual integration |
Type Safety | ⚠️ Optional | ✅ Full | PHP 8.1+ strict types |
Lines of Code | 100 | ~400 | More features, still minimal |
Installation & Setup
Requirements
- PHP 8.1+
- Composer
Installation
Optional Dependencies
Quick Setup
- Install Package:
composer require projectsaturnstudios/pocketflow-php
- Create Nodes: Extend
Node
orBaseNode
classes - Chain Workflows: Use
$node->next($nextNode, 'action')
- Run Flows:
$flow = new Flow($startNode); $flow->_run($shared);
LLM Integration Notes
Important: PocketFlow PHP is framework-agnostic and does not include LLM provider integrations. You need to:
- Choose Your LLM Client: OpenAI SDK, Guzzle HTTP, cURL, etc.
- Implement in Nodes: Add LLM calls in your
exec()
methods - Handle Responses: Process LLM responses in your
post()
methods - Manage State: Use
&$shared
parameters for conversation history
This approach gives you complete control over your LLM integrations without vendor lock-in.
Vendor Dependencies
Dependencies:
- ReactPHP: Required only for async features (optional)
- PHP 8.1+: Required for type safety and modern features
No Lock-ins:
- ❌ No specific LLM provider
- ❌ No specific HTTP client
- ❌ No specific framework
- ❌ No specific database
Contributing
This is the world's first PHP implementation of PocketFlow! We welcome contributions:
- 🐛 Bug Reports: Found an issue? Let us know!
- 🚀 Feature Requests: Ideas for PHP-specific features?
- 📖 Documentation: Help improve our docs
- 🧪 Examples: Share your PocketFlow PHP workflows
Roadmap
- [x] Core Framework: Basic node and flow implementation
- [x] Async Support: ReactPHP integration
- [x] Batch Processing: Array and parallel processing
- [ ] More Examples: Real-world workflow patterns
- [ ] Performance: Optimize for large-scale applications
- [ ] Testing: Comprehensive test suite
- [ ] Documentation: Full API documentation
License
MIT License - same as original PocketFlow
Acknowledgments
- Original PocketFlow: The-Pocket/PocketFlow - The inspiration and foundation
- ReactPHP: For async capabilities in PHP (optional dependency)
- PHP Community: For the amazing language ecosystem
Built with ADHD by Project Saturn Studios