Search by

phpclaw / phpclaw-symfony

phpclaw

phpClaw bundle for Symfony. AI agent engine for PHP.

Package info

github.com/phpclaw-php/phpclaw-symfony

Homepage

Issues

Documentation

Type:symfony-bundle

pkg:composer/phpclaw/phpclaw-symfony

Statistics

Installs: 11

Dependents: 0

Suggesters: 0

Stars: 3

v0.1.3 2026-10-10 00:11 UTC

This package is auto-updated.

Last update: 2026-10-10 00:13:13 UTC


README

phpclaw phpclaw

PHP Symfony License Downloads Tests Version

This is a read-only mirror, auto-published from phpclaw-monorepo. Please open issues and pull requests there, not here.

Give your Symfony app an agent, not a chatbot.

phpClaw is the AI layer for Symfony: bundle, console, Doctrine, all native.

Most "AI in Symfony" setups mean gluing an HTTP client to your app and hoping the prompt holds up. phpClaw is a real bundle: autowired as a service, driven by the console, backed by Doctrine, with tools that actually query your database instead of guessing.

Ask it something and it picks a tool, runs it against your live app, and answers with real data. No fine-tuning, no separate service to run.

Just ask

> How many users signed up this week?
> Tail the last 50 lines of the log at warning level
> Summarise today's error log
> What's the total in the orders table this month?

CLI

phpClaw Symfony CLI in action

The agent from your terminal, scriptable and CI-friendly:

bin/console phpclaw "how many users signed up this week?"
bin/console phpclaw "tail the last 50 error-level log lines" --stream
bin/console phpclaw:chat

phpclaw:chat opens an interactive session with slash commands; --conv-id, --continue and --trace are in the Symfony guide.

Programmatic use

Autowired via the container. Inject ClawInterface anywhere:

use PhpClaw\Contracts\ClawInterface;

class DashboardController extends AbstractController
{
    public function __construct(private readonly ClawInterface $phpclaw) {}

    public function summary(): JsonResponse
    {
        return $this->json(['summary' => $this->phpclaw->send('Summarise this week\'s signups.')->text]);
    }
}

REST API

phpClaw Symfony REST API response

Declared in config/routes.yaml, prefixed /phpclaw:

POST /phpclaw/send                          synchronous agent run
POST /phpclaw/chat/stream                   streamed response

Pause for approval and finish later

Off by default. Set PHPCLAW_DURABLE_RUNS=true (needs PHPCLAW_STORE_MESSAGES on) and every run is saved after each step. A tool that changes data then pauses the run instead of being refused: send answers 202 with the run id and the paused call, and the stream sends an approval_required event. A run that uses up PHPCLAW_DURABLE_STEP_BUDGET steps or PHPCLAW_DURABLE_DEADLINE_SECONDS seconds answers 202 with status suspended (stream event run_suspended) and is finished later.

GET  /phpclaw/runs                          runs waiting for the caller's decision
POST /phpclaw/runs/{runId}/approve          {"call_id": "..."} approve, then finish the run
POST /phpclaw/runs/{runId}/deny             {"call_id": "...", "reason": "..."} deny, then finish

These three routes answer 404 while durable runs are off. Only the user who started the run's conversation, or a ROLE_PHPCLAW_MANAGE_ALL holder, may decide it. The finished answer is added to that conversation. From the shell, bin/console phpclaw:runs list|approve|deny|resume|resume-due does the same as the run's owner; add bin/console phpclaw:runs resume-due to cron every minute. An interactive bin/console phpclaw keeps its Y/n prompt.

The REST API needs symfony/security-bundle, which this package only suggests. Install it and put a firewall over /phpclaw, or every call answers 401. That is correct behaviour, not a misconfiguration: every conversation is stored against the acting user identifier, so there has to be one.

Both require an authenticated user: a request without one is rejected with 401. Point security.yaml at whichever firewall protects the /phpclaw prefix. By default any authenticated user reaches the agent and its tools; set require_chat_role: true to demand ROLE_PHPCLAW_CHAT instead. ROLE_PHPCLAW_MANAGE_ALL grants two things together: reading every user's conversations, and the raw read-only SQL tool, which always requires that role.

Installation

composer require phpclaw/phpclaw-symfony

Symfony Flex registers the bundle for you. Copy the config, set a provider key in .env, then run:

bin/console phpclaw "hello"

Full setup, configuration, and provider options are documented at phpclaw.ai/docs/adapters/symfony.

Key features

✅ Native console commands: phpclaw, phpclaw:mcp-server, phpclaw:about, phpclaw:guide, phpclaw:stats, phpclaw:jobs:list, phpclaw:jobs:status, phpclaw:runs

✅ Doctrine-backed memory: conversation + key-value drivers via DBAL, plus a cache-store driver

✅ 2 Symfony-native tools: database (read-only SELECT via Doctrine DBAL), log tail (var/log/*.log). Opt-in: add PhpClaw\Symfony\Tools\DatabaseTool / LogTool under phpclaw.tools in config/packages/phpclaw.yaml, the same way as the core shell, HTTP and file tools

✅ Web Profiler integration: a dedicated data collector panel for every agent run

✅ REST API: routes ship enabled (PHPCLAW_API_ENABLED defaults to true); set it to false and both answer 403. Two endpoints: send and chat/stream

✅ Multiple AI providers: Anthropic, OpenAI, Groq, Gemini, Mistral, DeepSeek, Ollama, and any custom OpenAI-compatible endpoint

✅ Conversation memory: context carries across a session by default

How it fits together

Symfony → phpClaw Symfony bundle (PhpClawBundle) → phpClaw agent runtime → your configured AI provider

Documentation

This README gets you installed. Everything else (configuration, providers, memory, skills, Cloud, the full tool reference, REST API, CLI, code examples, upgrading, troubleshooting) lives at:

phpclaw.ai/docs/adapters/symfony

Contributing

Contributions are welcome. See the contributing guide.

Security

Please review our security policy for reporting vulnerabilities.

License

MIT. See LICENSE. Part of the phpClaw project.

Symfony is a trademark of Symfony SAS. phpClaw is an independent open-source project and is not affiliated with or endorsed by Symfony SAS.