PHPackages                             carmelosantana/php-agents - 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. carmelosantana/php-agents

ActiveLibrary[Framework](/categories/framework)

carmelosantana/php-agents
=========================

PHP 8.4+ agent framework — interfaces, tools, and providers for building AI agents

v0.10.2(1mo ago)13.5k↑147.4%20MITPHPPHP ^8.4CI passing

Since Feb 12Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/carmelosantana/php-agents)[ Packagist](https://packagist.org/packages/carmelosantana/php-agents)[ RSS](/packages/carmelosantana-php-agents/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (8)Dependencies (8)Versions (50)Used By (20)

php-agents
==========

[](#php-agents)

PHP 8.4+ framework for building AI agents with tool-use loops, provider abstraction, and composable toolkits.

Build agents that can read files, browse the web, execute code, and use custom tools — powered by any OpenAI-compatible API, Anthropic, or local models via Ollama.

 ```
graph LR
    APP[Your App] --> AGENT[Agent]
    AGENT --> PROVIDER[ProviderOpenAI / Anthropic / Ollama]
    AGENT --> TOOLS[Tools & ToolkitsFiles / Web / Shell / Memory]
    AGENT --> OBSERVER[ObserversLogging / Streaming / Metrics]
    PROVIDER --> LLM[LLM]
    LLM -->|tool calls| AGENT
    TOOLS -->|results| AGENT
```

      Loading Features
--------

[](#features)

- **Agentic tool-use loop** — automatic iteration: the LLM calls tools, processes results, and decides when it's done
- **Multi-provider** — Ollama (local), OpenAI, Anthropic, OpenRouter, or any OpenAI-compatible endpoint
- **Streaming + tool calls** — both OpenAI and Anthropic 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 base64 images to vision models (auto-converts between OpenAI and Anthropic formats)
- **Bundled agents** — `FileAgent`, `WebAgent`, `CodeAgent` ready to use out of the box
- **Composable toolkits** — filesystem, web, shell, and memory toolkits that snap onto any agent
- **Context window management** — automatic conversation pruning when approaching token limits
- **Observer pattern** — attach `SplObserver` to watch agent lifecycle events in real time
- **Security by default** — path traversal protection, SSRF blocking, shell injection detection
- **OpenClaw config** — centralized model routing with aliases, fallbacks, and per-provider settings
- **Zero framework coupling** — depends only on `symfony/http-client` and `psr/log`

Provider Feature Matrix
-----------------------

[](#provider-feature-matrix)

FeatureOpenAI CompatibleOllamaAnthropic`chat()`✅✅✅`stream()`✅✅✅`structured()`✅✅✅Tool calling✅✅✅Streaming + tool calls✅✅✅Image input (base64)✅✅✅`models()` list✅✅✅`isAvailable()`✅✅✅Requirements
------------

[](#requirements)

- PHP 8.4 or later
- Extensions: `curl`, `json`, `mbstring`
- Composer 2.x
- [Ollama](https://ollama.ai) (recommended for local inference)

Installation
------------

[](#installation)

```
composer require carmelosantana/php-agents

```

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

[](#quick-start)

Create an agent that can read files and answer questions about them:

```
