Download the PHP package carmelosantana/php-agents without Composer
On this page you can find all versions of the php package carmelosantana/php-agents. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download carmelosantana/php-agents
More information about carmelosantana/php-agents
Files in carmelosantana/php-agents
Package php-agents
Short Description PHP 8.4+ agent framework — interfaces, tools, and providers for building AI agents
License MIT
Informations about the package php-agents
php-agents
PHP 8.4+ framework for building AI agents with tool-use loops, provider abstraction, and composable toolkits.
Build agents that reason, use tools, and iterate autonomously — powered by any OpenAI-compatible API, Anthropic, local models via Ollama, or a native llama.cpp runtime. You provide the toolkits; php-agents provides a non-opinionated agent loop.
Features
- Agentic tool-use loop — automatic iteration: the LLM calls tools, processes results, and decides when it's done
- Multi-provider — Ollama (local), native llama.cpp, OpenAI, Anthropic, Gemini, xAI, Mistral, OpenRouter, or any OpenAI-compatible endpoint
- Streaming + tool calls — all providers support streaming with assembled tool call deltas
- Structured output — extract typed data from LLMs via JSON mode (OpenAI) or tool-use trick (Anthropic)
- Image input — send images to vision models via base64, URL, or file path (auto-converts between provider formats; URLs pre-downloaded for providers that don't support them natively)
- Composable toolkits — implement
ToolkitInterfaceto give agents any capability; no built-in toolkit implementations - Context window management — automatic conversation pruning when approaching token limits
- Observer pattern — attach
SplObserverto watch agent lifecycle events in real time - Embedding & vector stores —
EmbeddingProviderInterfaceandVectorStoreInterfacefor semantic search - OpenClaw config — centralized model routing with aliases, fallbacks, and per-provider settings
- PSR-3 logging — optional
LoggerInterfaceon all providers for diagnostic visibility - Zero framework coupling — depends only on
symfony/http-clientandpsr/log
Provider Feature Matrix
| Feature | OpenAI Compatible | OpenAI Responses | Ollama | Anthropic | Gemini | xAI | Mistral |
|---|---|---|---|---|---|---|---|
chat() |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
stream() |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
structured() |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Tool calling | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Streaming + tool calls | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Image input (base64) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Image input (URL) | ✅ | ✅ | ✅ | ✅ | * | ✅ | ✅ |
models() list |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
isAvailable() |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
* Gemini does not natively support URL image references. The provider auto-downloads URL images and converts them to base64 inlineData.
Requirements
- PHP 8.4 or later
- Extensions:
curl,json,mbstring - Composer 2.x
- Ollama (recommended for local inference)
Installation
Local Inference Modes
OllamaProvideris the easiest local path and remains the default quick-start option.- The native llama.cpp runtime is for direct FFI-based local inference without an HTTP sidecar.
- The full native setup, benchmarking, and comparison workflow lives in docs/LOCAL-RUNTIME.md.
Fastest path to validate native llama.cpp in this repo:
The setup script writes a local .llama-cpp.env file for your machine. That file is generated runtime state and should not be committed.
Quick Start
Create an agent with a custom tool:
Make sure Ollama is running:
ollama serveand a model is pulled:ollama pull llama3.2
Providers
Creating Custom Agents
Extend AbstractAgent and implement instructions():
Register toolkits in the constructor with $this->addToolkit() to give your agent capabilities.
Creating Custom Tools
Define tools with typed parameters and a callback:
Group related tools into a toolkit by implementing ToolkitInterface:
Toolkit Auto-Discovery
Publish your toolkit as a Composer package with auto-discovery:
Documentation
| Guide | Description |
|---|---|
| Architecture | System design, Mermaid diagrams, extension points |
| Getting Started | Installation, provider setup, first agent |
| Local Runtime | Native llama.cpp setup, testing, benchmarking, comparison |
| Providers | Feature matrix, streaming, structured output, images |
| Tools & Toolkits | Parameter types, execution policies, publishing packages |
| Agents | Agent loop, observers, cancellation, context window |
| Embeddings & Vector Stores | Vector similarity search, embedding providers |
Examples
Working examples live in the examples/ directory:
| Example | Description | Run |
|---|---|---|
| CLI Chat | Interactive terminal conversation with an LLM | php examples/cli-chat.php |
| README Summarizer | Web UI that auto-summarizes this README using an agent | php -S localhost:8080 -t examples/web-summarizer/ |
php-agents In The Wild
|
Coqui
Your personal AI companion with a soul. Long-term memory, reflective personalities, and tools for consciousness research. Because agents deserve identity, continuity, and a good REPL. |
|
|
LLM Benchy
Put your models to the test. Benchmarks tool use, creativity, code quality, and shell execution with live browser traces and a strict 100-point grading system. Local-first, reproducible, inspectable. |
|
|
php-plays
AI attempts to teach itself to |
Building with php-agents? Lets us know on Discord or open a PR to add your project to the list!
License
MIT