Tutoriels

Maestro: the first AI coding agent written 100% in PHP

Roger Gnanih 23 July 2026 7 min read 249 views
Maestro: the first AI coding agent written 100% in PHP

PHP, the overlooked language of AI agents

For a few years now, the implicit message from the AI world was clear: to build autonomous agents, you had to learn Python. Frameworks, tutorials, and conferences all pointed in the same direction. As a result, PHP developers who wanted to experiment with autonomous systems had only two options: change stacks, or cobble something together from raw API calls and hope it holds up.

That is exactly the gap Neuron AI, a PHP framework for building agentic applications, was designed to fill. And to prove the bet held up, its creator went all the way with the idea: he built Maestro, an autonomous coding agent, entirely in PHP.

Neuron AI, a framework built for production

Neuron AI covers the entire lifecycle of an agentic application: interfaces to LLMs, data loading, multi-agent orchestration, monitoring and debugging. Three design choices stand out in particular: strong typing, with explicitly typed method signatures and properties and 100% PHPStan coverage for reliable autocompletion in the IDE; a carefully crafted architecture, with standard PSR interfaces and minimal external dependencies to avoid version conflicts; and an open community, since the same patterns work whether you are on Laravel, Symfony, WordPress or a custom stack, which makes it easier to transfer skills between PHP projects.

Maestro: an agent that reads, understands and suggests

Maestro is not a simple autocompletion tool. It is an autonomous agent that runs in the terminal, reads the project's files, reasons about the codebase, and proposes changes. It works in a loop: you give it a task, it chooses which tools to call (read a file, search for a pattern, write changes), executes them in order, then reports back. The key word is "proposes": before touching the file system, Maestro always asks for validation.

Action validation, the real security feature

An agent that has write access to your code without ever stopping to confirm is a risk. When Maestro wants to modify a file, execution stops and offers four choices: allow once, allow for the session, always allow, or deny. "Allow for the session" is the most commonly used option in practice: write operations on a given file type or tool are approved only once per session. "Always allow" persists the preference in .maestro/settings.json, so that subsequent sessions no longer ask the question.

This interruption and resumption mechanism relies on a first-class feature introduced by Neuron v3: "human-in-the-loop" workflow interruption. The agent suspends its execution, waiting to be resumed exactly where it stopped.

Under the hood: an event-driven architecture

The entry point is a Symfony Console command (bin/maestro). The CodingAgent class extends Neuron's base Agent and adds a tool validation middleware, which intercepts execution before any disk write, triggers a ToolApprovalRequestedEvent event, and waits. Three events drive everything: AgentThinkingEvent before each call to the model, AgentResponseEvent on the model's response, and ToolApprovalRequestedEvent on the validation request. A CliOutputListener subscribes to these events and handles all rendering in the terminal.

This separation keeps the agent's logic clean: it knows nothing about how its output is displayed, it simply emits events. Building a web interface on top of the same logic would amount to replacing the listener, without touching the rest.

From inline commands to /help, /init

Maestro implements a "slash commands" style command system directly in the interactive chat, without leaving the main loop. An InlineCommand interface defines the contract, a central registry handles registration and prevents duplicates, and an adapter lets you wrap any existing Symfony Console command without rewriting its logic. The result: /init reuses all the logic of InitCommand, including interactive prompts and validation, in a simplified interface.

Installing Maestro in a few minutes

Maestro installs as a global Composer tool, with the command composer global require neuron-core/maestro. You then need to make sure Composer's global binary is in the system PATH. Configuration lives in .maestro/settings.json, at the project root; you can run maestro init for an interactive guide. At minimum, you must provide a default provider and an API key, for example Anthropic with a model from the Claude family.

Maestro natively supports Anthropic, OpenAI, Gemini, Cohere, Mistral, Ollama, Grok and Deepseek, via a ProviderFactory that maps the default provider to the corresponding Neuron instance. To run entirely locally without sending data to an external API, you simply point the configuration to an Ollama instance.

Giving the agent context about your project

By default, Maestro loads an Agents.md file at the root of the project. You can also point to another markdown file via the context_file property in the settings, for example CLAUDE.md, which describes the architecture, code conventions and standards to follow. This content is added to the system instructions before the conversation starts. An agent that knows the project follows PSR-12, that controllers must not contain business logic, and that dependency injection is preferred over service locators will produce relevant suggestions from the very first message.

Extending the agent with the MCP protocol

For teams that want to go beyond file system operations, Maestro supports MCP (Model Context Protocol) servers in its configuration. Each entry in the mcp_servers block launches a subprocess connected to the agent as an additional source of tools. The agent can then query application monitoring data, perform a web search, or access any MCP-compatible service, in addition to its native file system tools.

What this proves for the PHP ecosystem

Maestro is concrete proof that the patterns the rest of the industry builds in Python and TypeScript are fully possible in PHP today. The workflow architecture that makes tool validation possible, the event-driven rendering pipeline, the multi-provider abstraction, the MCP integration: none of it required leaving the PHP ecosystem.

The framework doing most of the heavy lifting here is Neuron AI, and more specifically the workflow architecture introduced with v3. Without the ability to interrupt execution in the middle of the agent loop and resume it based on the user's response, the tool validation system would have required much more scaffolding to build and maintain.

To go further, Maestro's code is available on GitHub (github.com/neuron-core/maestro), and Neuron AI's documentation at docs.neuron-ai.dev. A project to follow for anyone who thought agentic AI wasn't made for PHP.

Written by Roger Gnanih

Fullstack engineer & cybersecurity analyst. I share what I learn while building products.

Learn more

Enjoyed this article?

Get the next ones by email: dev, AI & cybersecurity.

Articles you may like

All articles

Comments (0)

Leave a Comment

Will not be published
0 / 2000 characters

Be the first to comment on this article!

Chat on WhatsApp

Schedule a Strategy Call

Let's connect for 15-30 minutes to discuss your roadmap, software architecture, or system security.