
AI is no longer just a hyped up futuristic concept; it's a present-day reality, reshaping how applications are built and how users interact with them. Naturally, businesses are looking for the competitive edge that this AI revolution brings, and developers themselves are frequently encountering and tinkering with AI tools.
However, if you're a PHP developer, you might be feeling a bit of a disconnect. You see all these amazing innovations, but since AI still has a connotation of being “Python-first”, it feels like you’re in the “wrong” language. And you dread having to rewrite your whole application in order to integrate AI functionality – or risk missing out on the AI wave if you don’t.
In a landscape as innovative as AI, is your PHP app at risk of falling behind? Do you need a new tech stack, or maybe a proprietary solution which risks vendor lock-in? Both of these options limit your flexibility and prevent you from leveraging your existing expertise.
But here’s the good news, which was also the core message of our webinar that we organized together with Valerio Barbera, CTO & co-founder of Inspector.dev and core engineer at Neuron AI: you can add powerful AI features directly into your PHP applications, without having to start over or learn an entirely new language.
You can watch the recording of the webinar, or continue reading this recap to get a high-level overview of how Neuron enables PHP developers to create and integrate stand-alone AI components into their existing PHP applications.
Building AI apps in PHP
Many of the leading AI services are accessed via APIs, which is how PHP already integrates with other third-party services such as payment gateways, CRMs, etc. It’s no surprise, then, that the PHP community is actively creating tools that facilitate interaction with the APIs of these AI services. We’re going to take a look at how the Neuron AI framework achieves this.
Neuron AI is an open source PHP package/framework designed to help developers build full-featured AI agents while staying in the PHP ecosystem. It is supported by Inspector.dev and is framework-agnostic, with the core mission of simplifying every stage of the AI application development lifecycle in PHP.
Neuron provides core components as well as an extensible architecture to facilitate the creation of powerful AI features. Since it is framework-agnostic, it can be used in standalone scripts or deeply integrated into a project based on Laravel, Symfony or any other PHP framework.
It enables observability thanks to its connection with Inspector.dev, allowing developers to monitor their AI agents in production, understand their performance and debug any issues that may arise.
One of the key benefits of using Neuron is minimizing vendor lock-in with the use of standard interfaces for different AI services such as LLMs, vector stores and embedding providers. This gives developers the invaluable flexibility of being able to switch between different services with minimal code changes.
What are AI agents?
While LLMs such as ChatGPT provide information based on prompts, AI agents are specialized programs which are able to perform tasks in response to prompts and take independent actions to complete those tasks. They can be easily connected with the unique context and services of a specific application, making them a great fit for handling processes that are complex and/or repetitive.
So, while a large language model does a great job at answering a question, an AI agent built with Neuron AI could, for example, research information across multiple internal documents, use an external API to fetch data, and then compile a report and save it to a database.
Other use cases include automated bug fix suggestions based on error analysis, management of support emails and drafting initial responses, monitoring of application data and alerting on anomalies, and many more.
How does Neuron work?
Neuron AI is built around a philosophy of modularity and extensibility, with a set of standard interfaces for all key components. This enables developers to easily swap out components throughout development, and thus change AI providers with minimal code changes rather than an entirely new application logic, as mentioned earlier.
It is easy to get started with Neuron, since it can be installed via a standard Composer command, and the basic agent structure as well as making a call to the LLM can be set up with just a few lines of code.
System Instructions are fixed instructions which allow developers to define an AI agent’s role, personality and how it should behave (background, steps), as well as the desired response format (output).
Features of Neuron
Neuron offers several features designed to address the shortcomings of standard/common AI tools. For example, LLMs are stateless, with each request being independent; Neuron solves this with a ChatHistory component, which can either keep the conversation in memory just for the current PHP execution, or persist it in a file to enable users to resume at a later time.
Another common LLM challenge is the inability of getting output in a consistent, predictable format. Neuron’s solution here is Structured Output, which enforces the AI agent’s output to conform to a PHP class schema defined by the developer themselves. It even offers retrying with validation feedback which significantly increases the reliability of getting structured data.
What truly makes Neuron’s AI agents shine, however, are Tools and Function Calls. Tools enable agents to interact beyond the pre-trained knowledge of the specific LLM, such as interacting with application services and/or external APIs.
Using tools, an AI agent is able to call special functions in your PHP code as needed. They facilitate fetching real-time data, accessing private data, and performing various actions such as sending emails or updating records.
Neuron offers some pre-built toolkits that allow developers to get started faster. These include integrations for Tavily and Jina which provide web search and content extraction capabilities, as well as the MCP Connector which connects agents to data sources and tools exposed by external servers. It’s also easy to create custom reusable tool classes by implementing the ToolInterface.
Monitoring agents in Neuron
As highlighted earlier on, Neuron AI provides built-in observability thanks to its smooth integration with Inspector.dev. Production-ready AI applications are often complex, with multiple LLM calls, tools used, and often multiple steps of retrieval-augmented generation (RAG) involved.
This makes it especially important to be able to monitor the performance of AI apps, identify issues and bottlenecks, and provide timely fixes to bugs and/or unexpected application behavior.
Inspector approaches this by providing not only the powerful AI Bug Fix feature (itself built with Neuron), but also a detailed look into the entire execution flow of an AI agent, from the tools used to analyses of how long each specific RAG retrieval takes. This is essential for building trust in and confidently deploying these AI systems.
Conclusion & next steps
We covered a lot of ground in this webinar, so we decided to focus on retrieval-augmented generation and how Neuron uses RAG in a future webinar. Stay tuned for more information on that, as well as for more content about PHP and development coming up soon.