How phpclaw-php/phpclaw works
phpClaw is a framework-independent PHP agent engine. A caller builds a Claw and sends a message; invocation lifecycle code applies guards and hooks, then the Agent runs a bounded ReAct loop using a provider and available tools, returning an AgentResponse. Conversation persistence, memory recall, streaming, structured output, pipelines, graph execution, provider fallback, skills, and discovery are additional capabilities. Arrows are limited to relationships explicit in the README or visible in indexed/read excerpts; unsampled subsystem links are omitted.
Main entry points: Agent.php ReAct agent · InvocationPipeline.php Invocation lifecycle · Claw.php Claw facade · Providers Provider adapters
Components 23
Agent entry
- Claw facade
src/Claw.php - Agent response
src/Agent/AgentResponse.php
Agent runtime
- Invocation lifecycle
src/Agent/InvocationPipeline.php - Input guards
src/Guards/GuardRegistry.php - ReAct agent
src/Agent/Agent.php
Agent capabilities
- Structured output
src/Agent/StructuredOutputRunner.php - Composable pipeline
src/Pipeline/Pipeline.php - Pipeline tool
src/Pipeline/PipelineTool.php - Graph execution
src/Graph/Graph.php - Skills
src/Skills - Attribute discovery
src/AutoDiscovery/AttributeScanner.php
Providers and tools
- Provider adapters
src/Providers - Tool registry
src/Tools/ToolRegistry.php - Tool routing
src/Tools/ToolRouter.php - Built-in tools
src/Tools - Read-only SQL tool
src/Tools/DatabaseQueryTool.php - Streaming transport
src/Http/StreamParser.php
State and events
- Memory drivers
src/Memory - Conversation history
src/Agent/Conversation.php - Lifecycle hooks
src/Hooks/HookDispatcher.php
Other components
- Application caller
- LLM service
- Application database
Connections 25
- Application caller → Claw facade: sends message
README.md - Claw facade → Invocation lifecycle: starts invocation
src/Claw.php - Invocation lifecycle → Input guards: scans input
src/Agent/InvocationPipeline.php - Invocation lifecycle → Lifecycle hooks: dispatches events
src/Agent/InvocationPipeline.php - Invocation lifecycle → ReAct agent: invokes agent
src/Agent/InvocationPipeline.php - Invocation lifecycle → Memory drivers: persists history
src/Agent/InvocationPipeline.php - Invocation lifecycle → Conversation history: appends turn
src/Agent/InvocationPipeline.php - ReAct agent → Provider adapters: requests completion
src/Agent/Agent.php - ReAct agent → Tool registry: executes tools
src/Agent/Agent.php - ReAct agent → Lifecycle hooks: fires events
src/Agent/Agent.php - ReAct agent → Agent response: returns result
src/Agent/Agent.php - Provider adapters → LLM service: sends requests
README.md - Tool registry → Tool routing: routes calls
src/Agent/Agent.php - Tool registry → Read-only SQL tool: dispatches tool
- Read-only SQL tool → Application database: queries SELECT
src/Tools/DatabaseQueryTool.php - ReAct agent → Memory drivers: recalls context
README.md - ReAct agent → Structured output: validates schema
README.md - Application caller → Composable pipeline: composes steps
src/Pipeline/Pipeline.php - Pipeline tool → Composable pipeline: invokes pipeline
src/Pipeline/PipelineTool.php - ReAct agent → Pipeline tool: calls as tool
- Application caller → Graph execution: defines execution graph
src/Graph/Graph.php - ReAct agent → Skills: uses skills
README.md - Application caller → Attribute discovery: scans attributes
src/AutoDiscovery/AttributeScanner.php - Provider adapters → Streaming transport: parses stream
- Claw facade → Agent response: returns response
README.md