Share
Embed
PHP & AI: Beyond the Hype
This deck belongs to a talk given at PHP UK 2026 in London.
At first AI is a ton of buzzwords and hype, but how do we integrate AI in our existing products / software projects in a meaningful and realistic manner?
Let's have a look how Symfony AI enables us to bring AI-based or even agentic features, not only chatbots, into our PHP applications or scaled architecture.
If you are looking for input on how to approach AI, need ideas where to get started or find out what's realistic at first - let this talk be your inspiration!
Christopher Hertel
February 28, 2026
Transcript
76 slides
-
P H P & A I B E Y O
N D T H E H Y P E 1 -
Agenda Fundamentals Basic Concepts & Terminology Symfony AI Initiative, Features
& Demo Model Context Protocol Distributed Agentic Applications 2 -
Christopher Hertel Software Engineer in Berlin Focus on PHP, Symfony
and GenAI Working on Tech Program of 3 -
Models & Inference AI Model Trained on data to predict
output based on inputs Strong Competition & Fast Innovation OpenAI, Google, Meta, Anthropic, Mistral, and more Various Capabilities Text, classification, streaming, structured output, multi-modal, real-time, tool calling Inference APIs Inference as a Service via HTTP, no local execution 5 -
Inference Platforms Model Vendor OpenAI, Anthropic, Mistral, Google, ... General
Cloud Provider Azure AI Foundry, Google Vertex AI, AWS Bedrock, ... Specialized Cloud Provider HuggingFace, Cerebras, OpenRouter, ... Local Runtimes Ollama, GPT4All, ONNX Runtime, ... 6 -
Context Stateless API Pre-trained, fine-tuned, but API "forgets" Limitation Size
of context varies per model, but limited Powerful Control Mechanism Efficient to steer and evaluate the models generation 7 -
Token Sequences of characters found in texts Not necessarily same
as words Foundation for GPT to understand semantics 8 -
Token Sequences of characters found in texts Not necessarily same
as words Foundation for GPT to understand semantics 9 -
Vector Expresses semantic meaning as numerical data Enables arithmetical operations
Higher Distance == Lower Similarity Typical range of dimensions 768 - 3072 11 -
PHP Libraries Listicle on GitHub Neuron AI neuron-core/neuron-ai Prism prism-php/prism
Symfony AI symfony/ai Today 12 -
Stats 1019 GitHub Stars 102 Contributors 2838 Commits 85 Packages
At 12:46 Today 16 -
Platform Component Abstraction Layer for Model Platforms Central Interface for
Inference Model Platform Bridges Multi-Modal Compatible Integrated Event System 20 -
Model Inference use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; use Symfony\AI\Platform\Message\{Message, MessageBag}; $platform = PlatformFactory::create($apiKey);
$input = new MessageBag( Message::forSystem('You are a pirate and you write funny.'), Message::ofUser('What is the Symfony framework?'), ); $result = $platform->invoke('gpt-5-mini', $input); echo $result->asText(); 5 6 7 8 9 10 11 12 13 14 15 16 17 27 -
OpenAI GPT use Symfony\AI\Platform\Bridge\OpenAi\PlatformFactory; $result = $platform->invoke('gpt-5-mini', $input); 5 use
Symfony\AI\Platform\Message\{Message, MessageBag}; 6 7 $platform = PlatformFactory::create($apiKey); 8 9 $input = new MessageBag( 10 Message::forSystem('You are a pirate and you write funny.'), 11 Message::ofUser('What is the Symfony framework?'), 12 ); 13 14 15 16 echo $result->asText(); 17 28 -
Anthropic Claude use Symfony\AI\Platform\Bridge\Anthropic\PlatformFactory; $result = $platform->invoke('claude-sonnet-4-5-20250929', $input); 5 use
Symfony\AI\Platform\Message\{Message, MessageBag}; 6 7 $platform = PlatformFactory::create($apiKey); 8 9 $input = new MessageBag( 10 Message::forSystem('You are a pirate and you write funny.'), 11 Message::ofUser('What is the Symfony framework?'), 12 ); 13 14 15 16 echo $result->asText(); 17 29 -
Google Gemini use Symfony\AI\Platform\Bridge\Gemini\PlatformFactory; $result = $platform->invoke('gemini-3-pro-preview', $input); 5 use
Symfony\AI\Platform\Message\{Message, MessageBag}; 6 7 $platform = PlatformFactory::create($apiKey); 8 9 $input = new MessageBag( 10 Message::forSystem('You are a pirate and you write funny.'), 11 Message::ofUser('What is the Symfony framework?'), 12 ); 13 14 15 16 echo $result->asText(); 17 30 -
Mistral use Symfony\AI\Platform\Bridge\Mistral\PlatformFactory; $result = $platform->invoke('mistral-large-latest', $input); 5 use Symfony\AI\Platform\Message\{Message,
MessageBag}; 6 7 $platform = PlatformFactory::create($apiKey); 8 9 $input = new MessageBag( 10 Message::forSystem('You are a pirate and you write funny.'), 11 Message::ofUser('What is the Symfony framework?'), 12 ); 13 14 15 16 echo $result->asText(); 17 31 -
Streaming $result = $platform->invoke('mistral-large-latest', $input, [ 'stream' => true, ]);
foreach ($result->asStream() as $word) { echo $word; } $input = new MessageBag( 10 Message::forSystem('You are a pirate and you write funny.'), 11 Message::ofUser('What is the Symfony framework?'), 12 ); 13 14 15 16 17 18 19 20 21 32 -
Audio, Image & PDF Input $input = new MessageBag( Message::ofUser(
'Describe the audio file.', Audio::fromDataUrl('data:audio/mpeg;base64,/9j/4AAQ...'), ), ); $result = $platform->invoke('gemini-2.5-flash', $input); echo $result->asText(); 10 11 12 13 14 15 16 17 18 19 Message::ofUser( 'Describe the audio file.', Audio::fromDataUrl('data:audio/mpeg;base64,/9j/4AAQ...'), ), $input = new MessageBag( 10 11 12 13 14 ); 15 16 $result = $platform->invoke('gemini-2.5-flash', $input); 17 18 echo $result->asText(); 19 33 -
Audio, Image & PDF Input Message::ofUser( 'What is visible on
the image?', new ImageUrl('https://example.org/elephant.jpg'), ), $input = new MessageBag( 10 11 12 13 14 ); 15 16 $result = $platform->invoke('gemini-2.5-flash', $input); 17 18 echo $result->asText(); 19 34 -
Audio, Image & PDF Input Message::ofUser( 'Describe the content of
the PDF file.', Document::fromFile('/path/to/document.pdf'), ), $input = new MessageBag( 10 11 12 13 14 ); 15 16 $result = $platform->invoke('gemini-2.5-flash', $input); 17 18 echo $result->asText(); 19 35 -
Structured Output Message::forSystem('Help users as math tutor, step by step.'),
Message::ofUser('how can I solve 8x + 7 = -23'), ); $input = new MessageBag( 10 11 12 13 14 $result = $platform->invoke('mistral-small-latest', $input, [ 15 'response_format' => MathReasoning::class, 16 ]); 17 18 dump($result->asObject()); 19 'response_format' => MathReasoning::class, $input = new MessageBag( 10 Message::forSystem('Help users as math tutor, step by step.'), 11 Message::ofUser('how can I solve 8x + 7 = -23'), 12 ); 13 14 $result = $platform->invoke('mistral-small-latest', $input, [ 15 16 ]); 17 18 dump($result->asObject()); 19 dump($result->asObject()); $input = new MessageBag( 10 Message::forSystem('Help users as math tutor, step by step.'), 11 Message::ofUser('how can I solve 8x + 7 = -23'), 12 ); 13 14 $result = $platform->invoke('mistral-small-latest', $input, [ 15 'response_format' => MathReasoning::class, 16 ]); 17 18 19 36 -
Object Population $city = new City(name: 'London'); $input = new
MessageBag(Message::ofUser( Template::string('Provide missing information for {city.name}'), )); $result = $platform->invoke('gpt-4o-mini', $input, [ 'template_vars' => ['city' => $city], 'response_format' => $city, ]); echo $result->asObject()->mayor; Sadiq Khan 38 -
Embeddings Models Semantic Vectors are LLMs little sibling $result =
$platform->invoke('text-embedding-3-small', $text); echo $result->asVector(); // array of floats 39 -
Hugging Face Integration with Hugging Face's Inference Hub API use
Symfony\AI\Platform\Bridge\HuggingFace\Task; $result = $platform->invoke('facebook/detr-resnet-50', $image, [ 'task' => Task::OBJECT_DETECTION, ]); echo $result->asObject(); // image classification result 40 -
Bundle Configuration # config/packages/ai.yaml ai: platform: openai: # or anthropic,
azure, google, more to come ... api_key: '%env(OPENAI_API_KEY)%' agent: default: model: 'gpt-4o-mini' prompt: 'You are a pirate and you write funny.' # more options ... store: chroma_db: symfonycon: collection: 'symfony_blog' # multi_agent, indexer, vectorizer ... 44 -
Agent Component Multi-Step Interaction with Model Combination of Things Platform
& Model Collection of Messages/Prompts as Context Memory, Tools, and more Various Architectures From static workflows to autonomous orchestration 46 -
Tool Calling App Provides Tools Exposed to tool via JSON
Schema definition as part of API call Model Invokes Tool As an intermediate response the model invokes a tool (or multiple) Tool Result Result of tool call provided as next call to model Instrumentation Log and analyze tool calls, model invocations, and results 49 -
Tool Calling use Symfony\AI\Agent\Toolbox\Attribute\AsTool; use Symfony\Component\Clock\ClockInterface; #[AsTool('cookbook_create_recipe', 'Creates a new
recipe in the cookbook.')] final readonly class CookbookCreateRecipe { public function __construct(private EntityManagerInterface $clock) {} /** * @param Recipe $recipe The recipe to create in the cookbook. */ public function __invoke(Recipe $recipe): string { // validate & persist recipe ... return 'Recipe created successfully!'; } } 51 -
Agent Tool Bridges 9 Agent Tool Bridges already, and more
to come ... 52 -
Multi-Agent Architectures Level of Autonomy & Context Sharing Implemented Workflows
Solved in user land Subagents as Tools Defined subtask & isolated context Orchestration with Handoff Central orchestrator agent & handsoff with context to subagents 54 -
Subagent as Tool # config/packages/ai.yaml ai: # Platform Configuration ...
agent: researcher: model: 'gpt-4o' prompt: 'You do heavy research.' smalltalker: model: 'gpt-4o-mini' tools: # Agent as tool 🤯 - agent: 'researcher' name: 'research_topic' description: 'Does research on a given topic.' 55 -
Orchestration # config/packages/ai.yaml ai: # Platform Configuration ... agent: orchestrator:
{ # agent config ... } technical: { # agent config ... } billing: { # agent config ... } fallback: { # agent config ... } multi_agent: support: orchestrator: 'orchestrator' handoffs: technical: ['bug', 'error', 'code', 'debug'] billing: ['invoice', 'payment', 'bill', 'order'] fallback: 'fallback' 56 -
Store Component Vector Store Abstraction Layer Lifecycle Management Adding &
Querying for Documents Document Indexing Pipeline 1. Loading 2. Filtering 3. Transforming 4. Vectorizing 60 -
Model Context Protocol (MCP) Open Sourced Protocol by Anthropic Only
release late 2024, already exploded to everywhere Two Main Components Defines MCP Server and MCP Client Standardizes Six Aspects [Server] Prompts, Resources, Tools [Client] Roots, Sampling, Elicitation JSON-RPC with Two Transports Stdio and Streamable HTTP 66 -
Symfony teamed up Symfony's MCP SDK Initially part of PHP-LLM
and Symfony AI PHP-MCP Organization Kyrian Obikwelu a.k.a. CodeWithKyrian The PHP Foundation Roman Pronskiy a.k.a. pronskiy Anthropic's MCP Team David Soria Parra a.k.a. dsp 72 -
PHP MCP SDK composer require mcp/sdk or composer require symfony/mcp-bundle
Still work in progress! 73 -
Bundle Configuration # config/packages/mcp.yaml mcp: app: 'app' # Application name
to be exposed to clients version: '1.0.0' # Application version to be exposed to clien # Configure this application to act as a MCP server # For now ONLY TOOLS client_transports: stdio: true # Enable STDIO via command http: true # Enable Server-Sent Event via controller # Configure MCP servers to be used by this application # NOT IMPLEMENTED YET servers: name: transport: 'stdio' # Transport method to use, either stdio: command: 'php /path/bin/console mcp' # Command to arguments: [] # Arguments to pass to the command http: url: 'http://localhost:8000/sse' # URL to SSE end 74 -
SDK Usage - Server Side use Mcp\Capability\Attribute\McpTool; use Symfony\Component\Clock\ClockInterface; #[McpTool('clock',
'Returns the current date and time.')] final readonly class Clock { public function __construct(private ClockInterface $clock) { } public function __invoke(): string { return $this->clock->now()->format('Y-m-d H:i:s'); } } 75 -
T H A N K YO U Q U E
S T I O N S ? 76