
Thank you for joining the course. In this short video we look at what we are going to learn, section by section, and then take a tour of the Udemy course player: the course content and your progress, the Resources of each lecture (slides PDF, source code ZIP and the GitHub branch of the lesson), the player controls (speed, notes, settings, the expanded view and keyboard shortcuts), how to ask a question in Q&A so that it is linked to the lecture you are watching, and how and why to leave an honest rating.
Meet the course: who it is for, why we build AI agents in PHP with NeuronAI, and what you will be able to build, from tools and memory to structured output, streaming, MCP, RAG, workflows and Laravel. We see how the course works: PhpStorm in every lesson, practice first, plain PHP before Laravel, Anthropic, OpenAI and Gemini in the videos, and Ollama as the free local option. Then a short demo in PhpStorm: we open a finished HelloAgent class and run it in the terminal to read a real answer from the model.
Installing php and composer and configuring PhpStorm
Installing php and composer and configuring Visual Code
We create the plain PHP project of the course with Composer: composer init with options writes composer.json, and we read each key, including the PHP 8.5 version constraint. By hand we add the license, a PSR-4 autoload rule that maps the App namespace to the src folder, and sort-packages. Then composer require installs NeuronAI and phpdotenv, and we read and run the environment check script, which reports PHP, the extensions, NeuronAI and which keys are set.
API keys are billed to you, so they never go into the code or into Git. We see where to get Anthropic, OpenAI and Gemini keys, then type a .env.example with the variable names and model names but empty keys, and a .gitignore that leaves out vendor, .env, the PHPUnit cache and the PhpStorm settings. With git init and git status we prove that Git cannot see .env, the environment check proves that PHP still reads the keys, and we see what to do if a key ever leaks.
We write our first NeuronAI agent in PhpStorm: a PHP class that extends Agent, with a provider() method that chooses the model and an instructions() method that sets the system prompt. A short script builds the agent with make(), names the conversation with setThreadId(), asks a question with chat() and reads the answer from the returned AgentState. Then we switch the same agent from Anthropic to OpenAI and Gemini by changing only the provider lines, while the script stays exactly the same.
Ollama runs open models on your own machine, with no key and no cost per call. We see how to install it on macOS, Windows and Ubuntu, then use ollama list, ollama pull, ollama run with its timings and ollama ps in PhpStorm's terminal. We switch our hello world agent to the Ollama provider by changing only the provider lines and run the same script on a local model. Finally we look at why local models can be slow: model size, memory, and GPU versus CPU.
We place AI features on a ladder with four rungs (the single call, the chatbot, the AI workflow and the agent) by asking one question: who decides what happens next, our code or the model. In PhpStorm we run our hello world agent as a single call, then add a second question on the same thread and print how many messages its history holds, which turns it into a chatbot. Then we sketch a workflow and an agent side by side in PHP, see that the real line between them is who writes the control flow, and learn why choosing the rung matters more than choosing the model.
A model cannot run code: it asks for a tool, our PHP runs it, and the result goes back as a new message until the model writes its answer, a loop that NeuronAI runs for us. In PhpStorm we write our first tool, a PackageVersionTool class with a name, a description, a properties method for its arguments and an __invoke method that asks Composer for an installed version, and we give it to HelloAgent with a tools method. Then a script prints every step of the run with getSteps, so we watch the model call our tool for one question and skip it for another, and see why tool descriptions, short results and the limit on tool runs matter.
Every request to a model carries the same four things: the model, the messages with their roles, the tools with their JSON schemas, and the generation parameters, and the provider keeps no session between calls. In PhpStorm we write a script that prints the model name, the system instructions and the JSON schema NeuronAI builds from our tool's properties, then walks through every message of a real run with its role, tool calls, tool results, stop reason and token usage. Finally we see why the system prompt is the specification of the whole agent, what a good one covers, and why the usage on every answer is our cost meter.
Tokens are the meter of every run: we see what a token is, why input and output tokens are priced apart, and why a request that outgrows the context window is rejected. In PhpStorm we write a script that runs our agent twice, once with a question that needs no tool and once with a question that needs our tool, timing each run with hrtime and adding up the calls and the tokens from the usage of every reply. With a table of example prices we estimate the cost of each run, see that a tool definition costs tokens on every call and that the input grows with every turn of the loop, and finish with three levers that bring cost and latency down.
Same prompt, same model, a different answer: we ask our hello world agent the same question five times, each time in a brand new conversation, and measure what changes. Our PhpStorm script prints the length and the time of every answer, counts how many different texts came back and checks whether each answer mentions the fact we expect, so we see that the wording varies while the facts and the shape stay stable. Then we see why it happens, with sampling one token at a time, what temperature can and cannot do, and how to test and build on structure and facts instead of exact words.
We build one small feature twice, telling the user which NeuronAI version is installed and what its three numbers mean: once as a single call where our PHP looks up the version, and once as an agent that decides to call our package version tool. A helper function in our PhpStorm script runs both versions the same way, so we can compare their steps, their time and how predictable each path is. Then we choose the rung with four questions in order (known steps, systems of record, irreversible actions and private knowledge) and finish with a challenge: placing four real features on the ladder yourself.
NeuronAI fits in our head as four pillars (the agent, the workflow, RAG and observability) and one design idea: providers, tools and message stores are all interfaces, so our code depends on a contract and the implementation is configuration. In PhpStorm we follow our HelloAgent into the vendor folder with Go to Declaration and Go to Implementation, find the pillars as folders, read AIProviderInterface with its more than twenty providers, the message store and the Tool contract, then write a script that asks PHP with class_implements which interfaces our agent, its provider and its tool implement. Finally we see why this design pays off in cost, vendor risk and local models, and what it costs us when a provider ships a feature of its own.
In NeuronAI the agent is a workflow: a graph of nodes where each node takes an event, does its work and returns the next event, and that event decides which node runs next. In PhpStorm we follow class Agent extends Workflow into the framework, read how chat() starts the graph, which nodes it lists and how ChatNode and ToolNode send the run back and forth, then write a script that subscribes to WorkflowNodeStart and prints every node of two live runs, one with a tool call and one without. Finally we see that RAG extends Agent with retrieval nodes in front, and why every workflow feature is also an agent feature.
NeuronAI ships a command line tool in vendor/bin whose make commands write agents, tools and workflows with the right shape, right where Composer's autoloader expects them. In PhpStorm we generate an AssistantAgent with make:agent, read the class before we touch it, fix its provider key and its instructions, and run it from a new script without dumping the autoloader. Then we compare the two styles of agent, extending Agent so the agent gets a name or composing one at runtime with Agent::make() and setters such as setAiProvider, setInstructions and addTool, and see that a setter always wins over its hook.
Instructions written as one long paragraph lose rules, grow contradictions and are hard to change, so NeuronAI's SystemPrompt class turns them into headed sections: background for identity, steps for the procedure, output for the shape of the answer, and toolsUsage for tool rules. In PhpStorm we run our assistant with its old prompt, write a small script that prints what getInstructions really sends as a system message, then rewrite the instructions into background, steps and output with one instruction per item. The same question to the same model then comes back in exactly the shape we asked for, and we finish with habits that keep a prompt healthy, such as positive rules and reviewing a prompt change like a code change.
Some facts the model needs change on every turn, like the date or an installed version, and putting them in the instructions breaks prompt caching and mixes stable rules with facts that expire. NeuronAI 4.1 adds a context() hook to the agent: in PhpStorm we read it in the framework, override it in our AssistantAgent to return the current time and the installed NeuronAI version as text blocks, and check that the printed prompt stays word for word the same. Then a script with two turns in one conversation shows fresh values on every call and a chat history that stores only our questions, and we decide where stable rules, facts of the turn and data needed only sometimes belong.
Every NeuronAI provider implements the same AIProviderInterface, so one agent can run on Anthropic, OpenAI, Gemini or Ollama without touching its instructions, its context or its tools. In PhpStorm we give our AssistantAgent a fluent useProvider method and a match expression with four arms, a key and a model for each cloud provider and a URL and a model for Ollama, then write a script that asks the same question on each provider with our version tool and prints who answered and how long it took. We compare the four runs in wording, precision and speed, see why provider options do not carry over, and why the choice of provider should be a value rather than a rewrite.
In this lab we wrap our assistant agent in assistant.php, a small command line tool in the project root that answers one question from its argument or chats line by line until we type exit, with the NEURON_PROVIDER variable picking the engine. In PhpStorm we write an env helper that reads settings from $_ENV, $_SERVER and getenv and treats an empty value as missing, a fail helper that writes to standard error and exits with code 1, and checks for an unknown provider or a missing key that run before any model call. Then we run it on Ollama, on Claude for a single command and in chat mode on OpenAI with our version tool, and break it on purpose to see one clear error line instead of a stack trace or an HTTP 403.
Build messages from content blocks and inspect their roles, metadata and token usage. Pass a conversation to the agent by hand and use examples to guide its answer. Compare the message objects with their serialized JSON.
Call the provider with and without a conversation transcript. Compare the answers and input tokens, then observe how an agent resends its history. See why remembered context depends on the messages our application supplies.
Compare memory, file and SQL message stores across separate PHP processes. Select a conversation with a thread ID and inspect its stored messages. Choose a store for the application and authorize access to each thread.
Build file and SQL message stores from configuration, compare persistence across processes, and authorize access to each conversation thread.
Run a conversation with a deliberately small context window and inspect the active and archived messages. Read how NeuronAI trims complete turns and budgets a request. Compare window sizing, summaries and durable facts as ways to manage growing conversations.
Separate conversation history from facts stored for a user. Carry a preference into a fresh thread while leaving the old transcript behind. Compare session memory, long term facts and retrieved knowledge, including their deletion requirements.
Extend the assistant CLI with persistent file or SQLite storage and a selectable thread. Restart the process, switch conversations and inspect the stored and active message counts. Implement /reset for one thread and keep the prompt usable after a provider error.
Verify persistent conversations across processes, isolate threads, clear one conversation with /reset, and handle invalid configuration and failed provider calls.
Inspect the name, description and JSON schema sent for a tool. Compare the provider-neutral definition with the actual model payload. See how that contract tells the model which inputs our PHP expects.
Build a tool class that receives a database connection. Give it a typed input schema and execute it through an agent. Separate dependencies supplied by our application from arguments chosen by the model.
Inject a database connection into a tool and agent, register the tool, inspect when the model calls it, and test the tool directly without a model.
Compare two descriptions for the same implementation. Observe the model’s choice and inspect the actual tool calls. Treat descriptions as part of the model prompt and evaluate their behavior.
Compose nested tool input schemas with scalar, array and object properties. Build a package compatibility tool and inspect its schema. Run it through an agent and compare the model inputs with the results.
Inspect how nested tool arguments arrive in PHP, handle omitted fields, and test list and object inputs directly and through an agent.
Define an attributed data class and use it as a structured tool input. Inspect the generated schema and the object received after binding. Compare required properties, defaults and the limits of schema metadata.
Read a built-in toolkit and build one for our project. Group tools with shared dependencies and add guidelines for choosing among them. Attach the toolkit in one line and observe two tools used in a real run.
Filter toolkits with only and exclude, configure a tool with with, and add tools at runtime. Inspect the Firecrawl toolkit without making a service request. Run a filtered combination of project and calculator tools.
Set tool execution budgets and inspect the framework guard. Compare a deliberately small limit with one that permits the task to finish. Catch the limit exception and inspect the tool run counters.
Control which tools are available for a given request. Inspect the tool definitions supplied to the model and compare role-dependent runs. Distinguish visibility from authorization in the application.
Observe an unhandled database tool exception and its effect on the run. Return structured error feedback so the model can respond to the failure. Inspect the default handler behavior and decide which errors should propagate.
Run native web search through the provider and inspect citations and usage. Compare it with a provider that rejects the same built-in tool. Weigh convenience against portability, observability and provider constraints.
Combine live city weather with a filtered calculator toolkit. Trace the weather lookups and arithmetic instead of trusting the model to calculate. Handle missing cities, service errors and tool execution limits.
Run a weather and calculator agent, inspect actual tool calls and counters, enforce per-tool limits, and verify missing-city error handling.
Build a database analyst with a server enforced read only connection. Inspect schema and analytical queries through filtered tools, then check the returned rows independently. Verify the reader account permissions directly at the database.
Run a read-only database analyst, verify generated SQL against independent queries, reject writes and private reads, and treat planted row instructions as data.
Compare plain JSON with wrapped text, changed field names and wrong value types. Build a small parser and inspect a real model response in PhpStorm. Separate a valid data shape from factual correctness before business code uses the result.
Define a dedicated Person data class with typed properties and SchemaProperty metadata. Inspect the generated schema, required fields, nullable values and defaults in PhpStorm. Separate schema constraints from ordinary PHP assignment and application validation.
Extract a typed Person from text using structured() and read its properties directly. Compare a per-call output class with an agent default supplied by getOutputClass(). Run both forms in PhpStorm and distinguish the returned DTO from the AgentState returned by chat().
Define nested output objects and typed arrays, inspect their generated schema, and validate a delivery containing an address and tags.
Separate the model schema from local validation. Inspect validation failures and bounded retries, and verify a coupon without confusing valid structure with factual correctness.
Compare a typed final response with a tool invocation. Follow the direction of the data and choose the contract that matches the application task.
Extract orders from email into nested objects. Check complete, incomplete, inconsistent and malformed inputs, preserving missing facts and reviewing totals against a catalog before persistence.
Extract orders from complete and incomplete emails, preserve contradictions, review candidates against an independent catalog, and inspect validation failures.
Inspect streamed TextChunk objects, preserve their exact boundaries, and compare the accumulated text with the completed AgentState. Measure first text separately from total request time.
Build a command line streaming runner that accepts a caller question, prints text as it arrives, and reports first text time, total time and final character count.
Handle tool calls, tool results and answer text in a streamed agent run. Correlate progress by call identifier and expose selected user-facing labels while handling incomplete replies.
Render tool argument previews, invocations, results and answer text by chunk type. Pair calls by identifier and verify diagnostic, user-facing and failed stream behavior.
Build messages with typed image and document content blocks. Inspect local fixtures and verify live responses against their actual contents.
Compare inline bytes, URLs and provider file identifiers. Upload a PDF through the IDE HTTP client, inspect mapped requests, and verify both inline and file reference responses.
Measure image bytes, reported input tokens, elapsed time and extraction checks across three representations. Choose an image size from observed task results and handle unavailable usage honestly.
Extract invoice documents into nested typed objects, validate rows and totals, and separate accepted, review and failure outcomes. Verify a distinct invoice against all mandatory source facts.
Run invoice extraction with integer cents and nested line items, distinguish application failure states, and verify arithmetic and source facts before acceptance.
This course contains the use of artificial intelligence.
AI was used for voice dubbing of the narration and for some of the screen recordings, to improve the quality of the course. All coding exercises and examples were verified by hand. An ebook with all the slides content included
AI features are moving from demos into real applications, and most of those applications are written in PHP. This course shows you how to build AI agents where your data and business rules already live, with NeuronAI, the agentic framework for PHP, and PHP 8.5.
This is a hands-on course for developers and software engineers. In the first section you set up PhpStorm, PHP and Composer (or the optional Docker environment) and run your first agent. From there every concept is shown running in code: we change one thing, run it, and look at what happened.
HOW AGENTS REALLY WORK
You learn what separates a single model call, a chatbot, a workflow and an agent, and why that choice matters more than the model. You watch the agent loop happen in your own runs, read the messages and the tool schemas that go to the model, and measure tokens, cost and latency. Then you open NeuronAI's source in PhpStorm to see how the framework is built.
BUILDING AGENTS IN PLAIN PHP
You write system prompts, swap providers in one line (Anthropic, OpenAI, Gemini and local models with Ollama), and give agents memory with message stores. You build tools and toolkits, guard the tool loop, return errors to the model instead of crashing, and get typed, validated output you can store in a database. You stream answers, send images and files to the model, and connect external tools through the Model Context Protocol.
TESTING, RAG AND FIRST WORKFLOWS
You trace every run and write deterministic tests with fake providers, so your CI stays green. You build retrieval augmented generation step by step: loaders, chunking, embeddings and vector stores, and you write your first event-driven workflows.
NEURONAI IN LARAVEL AND A CAPSTONE
You bring your agents into Laravel 13 with the SDK, the container and Eloquent memory. You finish with a capstone: a command-line agent that audits a PHP repository and writes a structured report.
The course is in production. New sections are added as they are recorded: check the curriculum to see the lessons available today.