Case Study
A first hands-on AI agent in PHP, built on Symfony AI
A small Symfony application built to get hands-on with Symfony's brand-new official AI component: an agent that summarises any text into three sentences using the OpenAI API (gpt-4o-mini). Built as companion code for a German-language tutorial I recorded – a compact, honest demo rather than a production app, with the new AgentInterface wired up end to end.
Tech stack
- Backend: PHP 8.4, Symfony 8.1
- AI: Symfony AI Bundle v0.11.0 (ai-bundle, ai-agent, ai-open-ai-platform) with OpenAI gpt-4o-mini
- Frontend: Twig, Symfony UX Turbo
Challenges & solutions
1. Symfony AI is a toolbox of 70+ packages, not one
The ai-bundle alone isn't enough. It needs the ai-agent component (Agent, MessageBag) and a separate provider bridge (here: ai-open-ai-platform) installed on top. The upside: swapping providers later – Anthropic, Gemini, a local Ollama model – means swapping the bridge package, not rewriting the application code.
2. Turbo silently swallows the response
The Symfony webapp skeleton ships with Symfony UX Turbo, which expects a redirect after a form POST. Without data-turbo="false" on the <form>, the server responds correctly but nothing renders in the browser – a reminder to check the network tab, not just server logs, when the UI "does nothing".
My role
Solo build, done to learn Symfony's new AI integration layer hands-on before using it in a real project – companion code to a German YouTube tutorial I recorded. Production concerns (form validation, CSRF, error handling, streaming) were deliberately left out, since they weren't the point of the exercise.
Result
A minimal, working AI agent – form to Agent to OpenAI to Twig – plus two documented gotchas for the next person (and my future self) building with Symfony AI.