How phpclaw-php/phpclaw-laravel works
phpClaw is a Laravel adapter for an agent runtime: users submit requests through Artisan, the REST API, or application code; the engine uses configured providers, tools, and memory to produce responses. The README documents the major capabilities, while sampled source confirms API handling, tool execution, memory routing, and queue-result management. Provider registration, MCP internals, Telescope recording, and several command implementations were not sampled, so their wiring is shown only where documented or omitted.
Main entry points: DatabaseRouterMemory.php Memory router · PhpClawServiceProvider.php Service provider · EngineFactory.php Engine factory · Tools Laravel tools
Components 23
Request interfaces
- REST routes
routes/api.php - API middleware
src/Http/Middleware/AuthenticatePhpClawApi.php - API controller
src/Http/Controllers/PhpClawController.php - Agent CLI
src/Console/PhpClawCommand.php - Laravel facade
src/Facades/PhpClaw.php
Agent integration
- Service provider
src/PhpClawServiceProvider.php - Engine factory
src/Engine/EngineFactory.php - Agent runtime
- AI provider
Agent capabilities
- Laravel tools
src/Tools - Database tool
src/Tools/DatabaseTool.php
Memory and jobs
- Memory router
src/Memory/DatabaseRouterMemory.php - Conversation memory
src/Memory/DatabaseConversationMemory.php - Key-value memory
src/Memory/DatabaseMemory.php - Cache memory
src/Memory/CacheMemory.php - Queue manager
src/QueueManager.php - Agent job
src/Jobs/RunAgentJob.php
Operations
- Telescope watcher
src/Telescope/PhpClawWatcher.php - MCP server command
src/Console/McpServerCommand.php
Other components
- User
- Laravel app
- Artisan user
- Laravel services
Connections 24
- User → REST routes: submits request
- REST routes → API middleware: passes request
- API middleware → API controller: authenticates
- API controller → Agent runtime: sends or streams
- Artisan user → Agent CLI: runs command
- Agent CLI → Agent runtime: sends request
- Laravel app → Laravel facade: calls agent
- Laravel facade → Agent runtime: delegates
- Service provider → Engine factory: builds engine
- Engine factory → Agent runtime: configures
- Engine factory → Laravel tools: resolves tools
- Agent runtime → AI provider: requests completion
- Agent runtime → Laravel tools: invokes tools
- Laravel tools → Database tool: includes
- Database tool → Laravel services: runs read-only SQL
- Service provider → Memory router: registers driver
- Agent runtime → Memory router: reads and writes memory
- Memory router → Conversation memory: routes conversations
- Memory router → Key-value memory: routes other namespaces
- Service provider → Cache memory: registers driver
- Queue manager → Agent job: dispatches job
- Queue manager → Memory router: polls stored results
- Service provider → Telescope watcher: registers watcher
- Artisan user → MCP server command: starts server