<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Môstka Jozef on Medium]]></title>
        <description><![CDATA[Stories by Môstka Jozef on Medium]]></description>
        <link>https://medium.com/@mostka.j?source=rss-f0ee32210d4e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*9iuzOGdJWvpWpRo_</url>
            <title>Stories by Môstka Jozef on Medium</title>
            <link>https://medium.com/@mostka.j?source=rss-f0ee32210d4e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 14:19:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mostka.j/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[End of ID Chaos: Type-Safe Identifiers in Symfony and Doctrine (Automated)]]></title>
            <link>https://medium.com/@mostka.j/end-of-id-chaos-type-safe-identifiers-in-symfony-and-doctrine-automated-71bee96cb371?source=rss-f0ee32210d4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/71bee96cb371</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[doctrine]]></category>
            <dc:creator><![CDATA[Môstka Jozef]]></dc:creator>
            <pubDate>Sun, 15 Mar 2026 13:31:15 GMT</pubDate>
            <atom:updated>2026-03-17T12:30:30.726Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*As9G1nj25MWMyq8UJtGopg.png" /></figure><p>When working with Symfony and Doctrine, it is common practice today to use UUIDs or ULIDs as entity identifiers. Most of the time, we represent them in code as strings or raw objects of type Uuid or Ulid.</p><p>This approach is functional, but it brings with it one subtle risk: <strong>type confusion</strong>.</p><h3>The Problem: When Everything is “Just” a UUID</h3><p>Imagine a method in Symfony Messenger or in a Controller that processes an order for a specific customer:</p><pre>// ❌ PROBLEM: Both parameters are technically the same (string/ULID)<br>final readonly class ProcessOrder<br>{<br>    public function __construct(<br>        public string $orderId,    // e.g. &quot;01JK...&quot;<br>        public string $customerId, // e.g. &quot;01JK...&quot;<br>    ) {}<br>}</pre><pre>// In coding, this can easily happen:<br>$bus-&gt;dispatch(new ProcessOrder(<br>    $customer-&gt;getId(), // ⚠️ OOPS! We swapped the order<br>    $order-&gt;getId()<br>));p</pre><p>Both parameters are technically strings. If you accidentally swap them when calling the constructor, PHP will not warn you. The application will attempt to find the order using the customer ID, resulting in an error that is sometimes not easy to detect immediately.</p><p>Oskar Stark, in his <a href="https://sensiolabs.com/blog/2025/type-safe-identifiers-symfony-doctrine">recent article on the SensioLabs blog</a>, suggests a solution: <strong>Custom ID classes for each entity.</strong></p><h3>The Solution: Type-Safe Identifiers</h3><p>Instead of a generic string or Ulid, we use dedicated classes OrderId and CustomerId.</p><pre>// ✅ SOLUTION: Each ID has its own type<br>final readonly class ProcessOrder<br>{<br>    public function __construct(<br>        public OrderId $orderId,<br>        public CustomerId $customerId,<br>    ) {}<br>}</pre><pre>// PHPStan or PHP itself will now stop you:<br>$bus-&gt;dispatch(new ProcessOrder(<br>    $customerId, // 🔴 FATAL ERROR: Argument #1 must be of type OrderId, CustomerId given<br>    $orderId<br>));</pre><h3>The Manual Way: Lots of “Boilerplate” Code</h3><p>While this idea is great, implementing it in pure Symfony requires several steps for every single entity:</p><ol><li>Create an ID class (e.g., BookId extending Ulid).</li><li>Create a custom Doctrine Type (e.g., BookIdType).</li><li>Register this type in doctrine.yaml.</li><li>Modify the entity to use this new type in the #[ORM\Column].</li></ol><p>For one entity, it’s fine. However, for a project with 20 entities, it’s repetitive and tedious work.</p><h3>Our Solution: Type-Safe Id Bundle</h3><p>That’s why we created the <a href="https://github.com/tito10047/type-safe-id-bundle"><strong>Type-Safe Id Bundle</strong></a>. Our goal was to take this correct architectural idea and make it almost invisible to the developer.</p><p>This bundle createnew command <em>make:entity:type</em> . When you create an entity, the bundle automatically generates everything you need for you.</p><h3>How does it work in practice?</h3><p>Just use the familiar command with an added flag:</p><pre>bin/console make:entity:type Product --with-ulid</pre><p><strong>The bundle automatically generates this code for you:</strong></p><ol><li><strong>ID Class (</strong>src/EntityId/ProductId.php<strong>):</strong></li></ol><pre>namespace App\EntityId;<br>use Symfony\Component\Uid\Ulid;<br><br>final class ProductId extends Ulid {<br>    public static function new(): self<br>    {<br>        return new self();<br>    }<br>}</pre><ol><li><strong>Entity with Type-Safe ID:</strong></li></ol><pre>#[ORM\Entity(repositoryClass: ProductRepository::class)]<br>class Product<br>{<br>    #[ORM\Id]<br>    #[ORM\GeneratedValue(strategy: &#39;CUSTOM&#39;)]<br>    #[ORM\CustomIdGenerator(class: &#39;doctrine.id_generator.universal&#39;)]<br>    #[ORM\Column(type: ProductIdType::class, unique: true)]<br>    private ProductId $id;<br><br>    public function __construct()<br>    {<br>        $this-&gt;id = new ProductId();<br>    }<br><br>    public function getId(): ProductId<br>    {<br>        return $this-&gt;id;<br>    }<br>}</pre><ol><li><strong>Enhanced Repository:</strong></li></ol><pre>class ProductRepository extends ServiceEntityRepository<br>{<br>    public function get(ProductId $id): ?Product <br>    {<br>        return $this-&gt;find($id-&gt;toString());<br>    }<br>}</pre><h3>Why start using Type-Safe IDs today?</h3><ol><li><strong>Elimination of logic errors:</strong> Swapping the IDs of two different entities is physically impossible.</li><li><strong>Cleaner code:</strong> Type-hints in constructors and methods clearly state what they expect.</li><li><strong>Better DX (Developer Experience):</strong> With our bundle, you don’t have to write any extra code. The make:entity command does all the &quot;dirty work&quot; for you.</li><li><strong>Easy integration:</strong> The bundle integrates directly into the Symfony workflow you are used to.</li></ol><h3>Installation</h3><p>If you want to try type-safe identifiers without unnecessary coding, install our bundle via Composer:</p><pre>composer require tito10047/type-safe-id-bundle</pre><p>Then enable it in config/bundles.php (if you don&#39;t use Flex), and you can start generating safe entities.</p><p><em>This bundle is currently in an experimental phase; we welcome any feedback or PRs on </em><a href="https://github.com/tito10047/type-safe-id-bundle"><em>GitHub</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=71bee96cb371" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Safety Parachute for Your Symfony Migrations: Introducing Migration Backup Bundle]]></title>
            <link>https://medium.com/@mostka.j/a-safety-parachute-for-your-symfony-migrations-introducing-migration-backup-bundle-ae7d3a3192bd?source=rss-f0ee32210d4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae7d3a3192bd</guid>
            <category><![CDATA[doctrine]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Môstka Jozef]]></dc:creator>
            <pubDate>Thu, 12 Mar 2026 15:55:24 GMT</pubDate>
            <atom:updated>2026-03-12T15:55:24.875Z</atom:updated>
            <content:encoded><![CDATA[<h3>Fear of doctrine:migrations:migrate during development?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*77yNaGhmqZdtPN_E4drGNg.png" /><figcaption>Migration backup</figcaption></figure><p>You know the feeling. You’re working on a new feature, changing the database schema, run a migration, and suddenly — boom! The third SQL command out of ten fails. You’re left with a broken local database in a half-applied state. Some changes were applied, others weren’t. Doctrine migrate can&#39;t roll back because it doesn&#39;t know exactly what passed. Manual repair is tedious, and you risk the consistency of the data you&#39;ve painstakingly prepared through fixtures.</p><p>For exactly these moments, we created the <strong>Migration Backup Bundle</strong> — your “safety parachute” for the development environment, which automatically creates a database backup just before the first migration is executed.</p><h3>What is Migration Backup Bundle?</h3><p>It is a lightweight Symfony bundle whose primary goal is to streamline and secure the developer workflow. Its philosophy is simple: <strong>not to get in the way of normal work, but to be there when something goes wrong while experimenting with migrations.</strong></p><p>While it is primarily intended for development (where schemas change most frequently and rapidly), nothing prevents its use in staging or production as an additional insurance policy. On production, we generally rely on more robust backup systems and migrations should ideally be well-tested by then, but “safety first” is a motto we understand.</p><h3>Key Features You’ll Love</h3><ul><li><strong>Full Automation</strong>: The backup is performed automatically by adding a parameter to the existing command.</li><li><strong>Broad DB Support</strong>: Whether you use <strong>MySQL</strong> (via mysqldump), <strong>PostgreSQL</strong> (via pg_dump), or <strong>SQLite</strong> (direct file copy), the bundle can handle it.</li><li><strong>Smart Optimization</strong>: Gzip compression support ensures that backups don’t take up unnecessary disk space.</li><li><strong>Automatic Cleanup</strong>: You can set backup rotation (e.g., keep only the last 10 files) to prevent the disk from filling up with old dumps.</li><li><strong>Extensibility via Events</strong>: The bundle triggers events (BackupStartedEvent, BackupFinishedEvent, BackupFailedEvent), so you can easily write your own logic, such as sending a Slack notification when a backup fails.</li></ul><h3>How it works “under the hood”?</h3><p>You might be wondering how we managed to add a new parameter to the standard Doctrine command without having to rewrite their code.</p><p>We use the power of the Symfony EventSubscriber. Our CommandSubscriber listens for the ConsoleEvents::COMMAND event. When it detects that doctrine:migrations:migrate is being executed, it dynamically inserts the --backup option (shortcut -b) into the command definition.</p><p>Then, if this flag is present, the bundle identifies your database, selects the correct driver, and uses Symfony\Component\Process to run the database&#39;s native tools for the fastest and most reliable data export.</p><h3>Quick Start: Safety is just seconds away</h3><p>Installation is straightforward:</p><pre>composer require tito10047/migration-backup</pre><p>Next, add a minimal configuration in config/packages/migration_backup.yaml:</p><pre>migration_backup:<br>    backup_path: &#39;%kernel.project_dir%/var/backups&#39;<br>    database: [&#39;default&#39;]<br>    keep_last_n_backups: 5<br>    compress: true</pre><p>And now the main part — running the migration with a backup:</p><pre>php bin/console doctrine:migrations:migrate --backup</pre><p>The console will immediately inform you of the successful backup: Backup of database default created in /project/var/backups/default-2026-03-12.sql.gz</p><h3>Why should you start using it today?</h3><ol><li><strong>Team Efficiency</strong>: Developers can experiment with schema changes without stress and revert in seconds if something goes wrong.</li><li><strong>Clean Dev Data</strong>: You no longer have to delete the database and rerun lengthy fixtures after every failed migration. Just restore the local backup.</li><li><strong>Additional Insurance</strong>: If you choose to use the bundle during deployment, you gain an immediate restore point from just before the incident, without having to find the last nightly backup in the cloud.</li></ol><h3>Conclusion and Call to the Community</h3><p>This project was born out of a real need to protect data during complex migrations. The project is open-source and can be found on GitHub: <a href="https://github.com/tito10047/migration-backup">tito10047/migration-backup</a>.</p><p>I’m really looking forward to feedback from the community during real-world use in various environments. If you have ideas for new drivers (e.g., for MS SQL or Oracle) or other improvements, don’t hesitate to open an Issue or a Pull Request.</p><p><strong>Remember: Backup before it’s too late. 😊</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae7d3a3192bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vibe Coding in Symfony: How SDC and AI “Memories” Helped Me Build a Project Without Writing Code]]></title>
            <link>https://medium.com/@mostka.j/vibe-coding-in-symfony-how-sdc-and-ai-memories-helped-me-build-a-project-without-writing-code-664c178db4fa?source=rss-f0ee32210d4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/664c178db4fa</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[twig]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Môstka Jozef]]></dc:creator>
            <pubDate>Thu, 19 Feb 2026 11:08:49 GMT</pubDate>
            <atom:updated>2026-02-19T11:31:10.278Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, I released the <a href="https://github.com/tito10047/ux-sdc"><strong>ux-sdc</strong></a> bundle, which brings the <strong>Single Directory Components (SDC)</strong> concept into the Symfony ecosystem. To test it in a real-world scenario, I decided to build a “smaller” project — <a href="https://formalitka.mostka.sk/">Formalitka</a>.</p><p>Given the current hype surrounding <strong>“Vibe Coding”</strong> (developing apps using natural language and AI agents like Junie), I figured I’d be a poor developer if I didn’t give it a shot.</p><h3>My “Vibe” Assignment was clear:</h3><ol><li><strong>Pure Plain CSS:</strong> No Tailwind, no Bootstrap. I wanted to prove that modern CSS in 2026 is powerful enough to handle styling without utility frameworks.</li><li><strong>SDC Structure:</strong> Everything must run on my bundle, keeping logic, templates, and styles in a single directory.</li><li><strong>Design in AI’s Hands:</strong> I’ll admit, CSS isn’t my strongest suit. The AI had to design the UI itself and maintain consistency across all subpages.</li><li><strong>Backend and Administration:</strong> The AI agent (Junie) was tasked with building the business logic and a full administration via EasyAdmin with minimal assistance from me.</li></ol><h3>The Problem: When AI Loses Context in a Monolith</h3><p>In traditional projects where files are scattered (PHP in src, Twig in templates, CSS in assets), I always hit a wall. The AI simply couldn&#39;t maintain design consistency. With massive CSS files stored in a single folder, the AI had no idea where to find the specific block of code related to a particular HTML snippet. It would start hallucinating, eventually creating a completely different visual style on one page compared to the last.</p><h3>The Solution: ux-sdc as an “AI-Native” Architecture</h3><p>It turns out that what makes code organized for humans makes it even better for AI. I simply updated the .guidelines for Junie to explain how to handle the SDC structure, and everything started working automatically.</p><p>Throughout the entire development process, I didn’t encounter a single major issue. Sure, the AI occasionally drifted from the established design, but thanks to SDC, I just had to say: <em>“This design is terrible; look at the homepage and unify it.”</em> Since the CSS files are small and isolated for each component, the AI knew exactly where to look.</p><h3>Isolation as the Ultimate Weapon</h3><p>The biggest advantage is that the components are isolated. When the AI changed something in one folder, I had 100% certainty it wouldn’t break anything else on the rest of the site.</p><h3>The EasyAdmin Story: Administration as a Puzzle</h3><p>What truly blew me away was the creation of the administration panel. I told the AI to build a complete admin using <strong>EasyAdmin</strong>, and it did so without me writing a single line of code. Building with EasyAdmin is like a puzzle for AI — and solving puzzles is what AI does best.</p><p>It even integrated AI image generation tools for me:</p><ul><li>I said: <em>“Let’s implement AI image generation. I have a Messenger message ready; create a button in the admin to trigger it.”</em></li><li>It automatically added grouped buttons to the interface, and now I can send commands to the Messenger with one click. The AI wrote the entire logic (Messenger + AI generation) itself with only minor corrections from my side.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*irCub0Rte3n_APFOAXmVYA.png" /></figure><h3>The Secret Ingredient: AI Guidelines and “Memories”</h3><p>The key to efficiency is the <strong>guidelines</strong> — a manual for the AI on how to work with your code. I instructed the AI that every time it implements a new feature, it must record a “memory” in the guidelines.</p><p>Because of this:</p><ul><li>The AI always knew what it had already done and had access to that context.</li><li>It didn’t perform tasks duplicately.</li><li><strong>The Game Changer:</strong> The guidelines file becomes a living documentation of the project. While it requires occasional “pruning” because the AI records every little detail, the order it brings to the project is worth it.</li></ul><p>You can see my .guideline in slovak language <a href="https://mdshare.vercel.app/guidelines-012c97">here</a></p><h3>The Comparison: Classic Development vs. SDC Vibe Coding</h3><pre>| Activity           | Classic Symfony Approach                         | SDC + Vibe Coding                                          |<br>|--------------------|--------------------------------------------------|------------------------------------------------------------|<br>| **Finding Files**  | Navigating through 4 directories for one change. | Everything is in one component folder.                     |<br>| **AI Context**     | AI hallucinates paths and breaks global CSS.     | AI has an isolated context and surgical precision.         |<br>| **Assets**         | Manual AssetMapper or Webpack configuration.     | **Zero Config** – the bundle handles assets automatically. |<br>| **Developer Role** | A &quot;coder&quot; searching for syntax errors.           | An **Architect** managing system growth.                   |</pre><h3>Results: 21 Components and Pure Joy</h3><p>The project currently consists of 21 isolated components. The structure is stable, and both I and the AI find it incredibly easy to navigate. SDC has brought the joy of visual design back to me.</p><p><strong>Here is what a component structure looks like in practice:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*1iifY8zlgFr9flW-JXASvA.png" /></figure><h3>Conclusion: Are You Still Coders or Already Architects?</h3><p>Vibe Coding with the <strong>ux-sdc</strong> bundle gave me the freedom to stop worrying about where a bracket goes or which file path I need. I focus on the business logic and the user experience.</p><p>My message to the community is simple: <strong>“If you want to use AI agents effectively, give them order and teach them to remember.”</strong> AI isn’t omnipotent; it’s only as good as the context you provide.</p><p>Try out the <a href="https://github.com/tito10047/ux-sdc">UX SDC Bundle</a> and start building projects that practically “write themselves.” The future of Symfony UX lies in clarity, organization, and SDC.</p><p><em>What do you think about this approach? Would you dare to let an AI write “memories” into your project guidelines? Let me know in the comments!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=664c178db4fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony UX: Single Directory Components (SDC) — The Path to Cleaner Architecture Without Tailwind]]></title>
            <link>https://medium.com/@mostka.j/symfony-ux-single-directory-components-sdc-the-path-to-cleaner-architecture-without-tailwind-9eab657cc97d?source=rss-f0ee32210d4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/9eab657cc97d</guid>
            <category><![CDATA[ux-component]]></category>
            <category><![CDATA[tailwind-css]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[twig]]></category>
            <dc:creator><![CDATA[Môstka Jozef]]></dc:creator>
            <pubDate>Tue, 27 Jan 2026 19:28:27 GMT</pubDate>
            <atom:updated>2026-01-28T07:21:21.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>Symfony UX: Single Directory Components (SDC) — The Path to Cleaner Architecture Without Tailwind</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uGqoO1HrAgeb1tjLwey9AQ.jpeg" /><figcaption>Single directory components</figcaption></figure><p>Frontend development in Symfony has taken a huge leap forward in recent years. Thanks to <strong>Symfony UX</strong> and <strong>Twig Components</strong>, we’ve gained the ability to write reusable components much like in React or Vue. However, the more components you have, the more you encounter one annoying problem: <strong>files are scattered across the entire project.</strong></p><p>A PHP class in src/Components, a Twig template in templates/components, CSS in assets/styles, and JavaScript somewhere else entirely. When you want to change the color of a button, you&#39;re looking at a trip through four different directories.</p><p>Some time ago, Hugo Alliaume published a great article <a href="https://hugo.alliau.me/blog/posts/a-better-architecture-for-your-symfony-ux-twig-components">A Better Architecture for Your Symfony UX Twig Components</a>, where he proposed the concept of <strong>Single Directory Components (SDC)</strong>. The idea is simple: let’s have everything in one folder.</p><p>Today, we’ll show you how to take this concept to the next level, completely get rid of manual configuration, and maybe even Tailwind.</p><h3>Why Single Directory Components (SDC)?</h3><p>If you’ve ever worked with Angular or Vue, you know that feeling of order. An Alert component is a single folder containing everything essential.</p><p>In the SDC approach, it looks like this:</p><pre>src_component/<br>└── UI/<br>    └── Button/<br>        ├── Button.php           # Logic<br>        ├── Button.html.twig     # Template<br>        ├── Button.css           # Styles<br>        └── Button_controller.js # Interactions (Stimulus)</pre><p><strong>Main Advantages:</strong></p><ol><li><strong>Maintainability:</strong> When you no longer need a component, you just delete one folder.</li><li><strong>Developer Experience:</strong> No context switching between distant folders.</li><li><strong>Isolation:</strong> Styles and scripts belong only to that one component.</li></ol><h3>Is Tailwind Passé? The Power of Native CSS and Variables</h3><p>Lately, there’s more and more talk about how, with the arrival of modern CSS features (like CSS variables, nesting, @layer), the need for utility frameworks like Tailwind is decreasing. Articles like <a href="https://medium.com/loop-of-thought/tailwind-was-never-the-answer-efc42ac3f83b">Tailwind Was Never the Answer</a> remind us that pure CSS is stronger today than ever before.</p><p>The SDC approach plays right into this trend. When you have a CSS file right next to your PHP class, you don’t need to write 20 Tailwind classes in your HTML. You can define clean, semantic CSS that uses CSS variables linked directly to PHP logic.</p><h3>Our Solution: UX SDC Bundle</h3><p>Hugo’s article showed how to set up SDC manually. However, it requires changes to composer.json, Twig configuration, AssetMapper, and Stimulus.</p><p>Our bundle tito10047/ux-sdc does it for you. It&#39;s a <strong>Zero Configuration</strong> solution. Just install the bundle and mark the class with an attribute.</p><pre>#[AsSdcComponent(&#39;UI:Button&#39;)]<br>class Button {<br>    // The bundle automatically finds Button.html.twig, Button.css, and Button_controller.js<br>}</pre><h3>The “Magic” Inside (Without Performance Loss)</h3><p>The bundle solves technical challenges that you would have to patch yourself with a manual approach:</p><ul><li><strong>Asset Orchestration:</strong> CSS and JS files are injected into the page <strong>only when</strong> the component is actually rendered.</li><li><strong>No More “Phantom” Controllers:</strong> You don’t have to create an empty Stimulus controller just so AssetMapper knows about your CSS. The bundle handles it for you.</li><li><strong>HTTP Preload &amp; FOUC:</strong> We automatically generate Link headers for HTTP preload. The browser starts downloading CSS even before it starts parsing HTML. This eliminates the annoying flash of unstyled content (FOUC).</li><li><strong>Production Performance:</strong> Thanks to a compiler pass, no disk scanning happens in production. Everything is pre-prepared in the cache.</li></ul><h3>Real-world Example: Project “Formalitka”</h3><p>What does it look like in the real world? Take a look at the project <a href="https://formalitka.mostka.sk/">formalitka.mostka.sk</a>. The entire UI kit is built on SDC without a single line of Tailwind.</p><p>Let’s take their Button component. The PHP class defines properties like color or size. The CSS then processes these properties using variables:</p><pre>/* Button.css */<br>@layer components {<br>    .button {<br>        background: var(--color-primary);<br>        color: var(--color-on-primary);<br>        transition: var(--transition);<br>        <br>        &amp;.button--secondary {<br>            background: var(--color-secondary);<br>        }<br>    }<br>}</pre><p>Thanks to SDC, this complex component (containing seal animations, sounds, and special effects) is contained within one directory and is easy to maintain.</p><h3>How to Get Started?</h3><p>Installation is lightning fast:</p><pre>composer require tito10047/ux-sdc</pre><p>Register the bundle and in config/packages/ux_sdc.yaml, set where your components reside:</p><pre>ux_sdc:<br>    ux_components_dir: &#39;%kernel.project_dir%/src_component&#39;<br>    component_namespace: &#39;App\Component&#39;</pre><p>And add the asset placeholder to your base.html.twig:</p><pre>&lt;head&gt;<br>    {{ render_component_assets() }}<br>&lt;/head&gt;</pre><p>That’s it. From this moment on, just create directories and write code.</p><h3>Performance Under the Microscope: Proof Instead of Promises</h3><p>When automation and “magic” come into play, the question often arises: <em>What about performance?</em> We put the SDC approach to a stress test with 500 unique components. Here are the key findings from our benchmarks:</p><pre><br>| Scenario                   | Classic Approach | SDC Approach  | Difference |<br>|:---------------------------|:-----------------|:--------------|:-----------|<br>| **Warmup (Prod)**          | 583.1 ms         | 586.2 ms      | +3.1 ms    |<br>| **Render (Prod Runtime)**  | 26.5 ms          | 31.6 ms       | +5.1 ms    |<br>| **Render (Dev Runtime)**   | 26.5 ms          | 88.4 ms       | +61.9 ms   |</pre><p><strong>What does this mean in practice?</strong></p><ul><li><strong>In production, the overhead is almost zero.</strong> Thanks to the compiler pass, no disk scanning happens at runtime. Rendering a single component has an overhead of only about <strong>8.8µs</strong>, a negligible price for fully automated asset and Stimulus management.</li><li><strong>Dev mode is optimized for DX.</strong> Instead of having to clear the cache every time a file changes, the bundle in dev mode uses <strong>runtime autodiscovery</strong>. It scans the disk only for those components that are currently being rendered. This means that if you add a new CSS file or change a Twig template, you see the changes immediately. Thanks to internal metadata caching within a single request, repeated rendering of the same component remains very fast.</li><li><strong>Memory Footprint:</strong> With 500 components, the bundle consumes about 8MB more memory during container compilation, which is perfectly fine for modern applications.</li></ul><p>You can find the full report in our <a href="https://github.com/tito10047/ux-sdc/blob/main/benchmark.md">benchmark.md</a>.</p><h3>The Future and Your Feedback (Version 0.1.0)</h3><p>This bundle is currently in version <strong>0.1.0</strong>. It’s an early stage where I’m looking for the right path. I wrote this article not only to share our solution but mainly to get feedback from you, the community.</p><p>We’re interested in:</p><ul><li>What do you think about the proposed API?</li><li>Is there anything missing that you would expect in an SDC approach?</li><li>Do you see any pitfalls in this approach that we’ve overlooked?</li></ul><p>We want this bundle to be built on solid foundations and real developer needs from the first stable version. Every GitHub issue, discussion, or comment moves us forward.</p><h3>Conclusion</h3><p>Single Directory Components combined with modern CSS are changing the way we think about Symfony UX. We’re getting rid of unnecessary boilerplate code, cleaning up our project structure, and increasing our performance as developers.</p><p>Try the <a href="https://github.com/tito10047/ux-twig-component-asset">UX SDC Bundle</a> and say goodbye to scattered files. The future of Symfony UX is in order and clarity.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9eab657cc97d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Writing srcset Manually: The Ultimate Image Solution for Symfony]]></title>
            <link>https://medium.com/@mostka.j/stop-writing-srcset-manually-the-ultimate-image-solution-for-symfony-28d2e5319883?source=rss-f0ee32210d4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/28d2e5319883</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[twig]]></category>
            <category><![CDATA[stimulus-package]]></category>
            <category><![CDATA[symfony-ux]]></category>
            <dc:creator><![CDATA[Môstka Jozef]]></dc:creator>
            <pubDate>Wed, 07 Jan 2026 16:42:43 GMT</pubDate>
            <atom:updated>2026-01-12T09:49:21.252Z</atom:updated>
            <content:encoded><![CDATA[<p>Don’t have premium? read at <a href="https://dev.to/tito10047/stop-writing-srcset-manually-the-ultimate-image-solution-for-symfony-59cn">dev.to</a></p><h3>Solving the Image Problem in Symfony: Meet PGI</h3><p>Images are the heaviest part of the modern web. They are responsible for slow page loads, frustrating Cumulative Layout Shift (CLS), and a nightmare developer experience when trying to implement truly responsive designs. If you’ve ever wrestled with complex &lt;picture&gt; tags or manually calculated srcset values for different breakpoints, you know the pain.</p><p>Enter <a href="https://github.com/tito10047/progressive-image-bundle/"><strong>PGI</strong></a> (Progressive Image Bundle) — the new standard for image handling in Symfony 6.4 and newer versions.</p><h3>The Hook: Why Core Web Vitals Changed Everything</h3><p>Google’s Core Web Vitals — specifically Largest Contentful Paint (LCP) and Cumulative Layout Shift (CLS) — have transformed how we build websites. It’s no longer enough to just “show an image.” You need to show it fast, and you must ensure the layout doesn’t jump when the image finally appears.</p><p>For many Symfony developers, achieving a perfect 100/100 PageSpeed score while maintaining a clean codebase has felt like a trade-off. You either spend hours writing custom responsive logic or you settle for “good enough” performance. PGI was born to eliminate that trade-off.</p><h3>Code Showcase: From Messy to Masterful</h3><p>Let’s look at the difference. A standard responsive image in Twig often looks like this:</p><pre>&lt;img src=&quot;{{ asset(&#39;images/hero.jpg&#39;) }}&quot; <br>     srcset=&quot;{{ asset(&#39;images/hero_sm.jpg&#39;) }} 600w, {{ asset(&#39;images/hero_lg.jpg&#39;) }} 1200w&quot;<br>     sizes=&quot;(max-width: 600px) 100vw, 50vw&quot;<br>     width=&quot;1200&quot; height=&quot;675&quot;<br>     loading=&quot;lazy&quot;<br>     alt=&quot;Hero image&quot;&gt;</pre><p>And that’s just for <em>one</em> aspect ratio. With PGI, you get a clean, Tailwind-inspired syntax:</p><pre>&lt;twig:pgi:Image <br>    src=&quot;images/hero.jpg&quot; <br>    sizes=&quot;sm:12@square md:6@landscape&quot;<br>    alt=&quot;Responsive hero image&quot; <br>    preload<br>/&gt;</pre><h3>Real-world Case: <a href="https://just6words.com/">just6words.com</a></h3><p>To see PGI in action, let’s look at how it handles a single image across different devices using an example from <a href="https://just6words.com/">just6words.com</a>.</p><p>Instead of writing multiple &lt;img&gt; tags or complex &lt;picture&gt; logic, you define everything in one place:</p><pre>&lt;twig:pgi:Image <br>    src=&quot;realcase.jpg&quot; <br>    sizes=&quot;sm:12@square md:6@landscape&quot; <br>    alt=&quot;Responsive real-world example&quot;<br>/&gt;</pre><h4>What happens on different devices?</h4><ul><li><strong>Mobile (sm):</strong> The browser loads a <strong>Square (1:1)</strong> crop. It takes the full width of the container.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*5XXzaADb3Ev4xSwbcRCt6g.jpeg" /></figure><ul><li><strong>Tablet/Desktop (md+):</strong> The browser automatically switches to a <strong>Landscape (16:9)</strong> crop. The image now occupies only half of the grid (6/12 columns).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/384/1*AWl-qIxTDlLeQGYjHLLGsQ.jpeg" /></figure><h4>Rendered HTML (Clean &amp; Semantic)</h4><pre>&lt;div class=&quot;progressive-image-container&quot; <br>     data-tito10047--progressive-image-bundle--progressive-image-hash-value=&quot;LMJ*@px@B@iwPnkCVXWqFjn,$%X9&quot;<br>     style=&quot;--img-width-sm: 640px; --img-aspect-sm: 1; --img-width-md: 384px; --img-aspect-md: 1.7777777777778;&quot; ...&gt;<br>    &lt;canvas ...&gt;&lt;/canvas&gt;<br>    &lt;img src=&quot;/realcase.jpg&quot; <br>         srcset=&quot;/media/cache/640x640/realcase.jpg 640w, /media/cache/384x216/realcase.jpg 384w&quot; <br>         sizes=&quot;(min-width: 768px) 384px, (min-width: 640px) 640px, 100vw&quot; ...&gt;<br>&lt;/div&gt;</pre><h4>What’s happening here?</h4><ul><li>sm:12@square: Full width on small screens, automatically cropped to 1:1.</li><li>md:6@landscape: Half width (6/12 columns) from medium breakpoint, automatically cropped to 16:9.</li><li>xl:[430x370]: Need a very specific size for a custom layout? PGI supports arbitrary values directly in the sizes attribute.</li><li>preload: PGI automatically injects a &lt;link rel=&quot;preload&quot;&gt; into your &lt;head&gt;, optimizing your LCP score instantly.</li></ul><h4>The “Progressive” in PGI: Blur-up Experience</h4><p>One of the most satisfying features for users is the built-in <strong>Blurhash</strong> support. Instead of showing a blank space or a generic spinner, PGI renders a beautiful, ultra-lightweight blurred version of the image immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*3sxGRx_eofLOP4rEfUlWtw.png" /></figure><p>This “blur-up” technique significantly improves <strong>perceived performance</strong>. Users see the layout and the context of the image instantly, even on slow connections, while the high-resolution version loads in the background. Once ready, the high-res image smoothly fades in, replacing the placeholder.</p><h3>Technical Deep Dive: Zero CLS and CSS Magic</h3><p>How does PGI prevent layout shift? It’s not just about adding width and height attributes. PGI leverages modern CSS aspect-ratio and CSS variables.</p><p>When the component renders, it calculates the aspect ratio based on your sizes definition. It then wraps the image in a container that reserves the exact space needed. No more content jumping as images load—even if the image is lazy-loaded or slow to arrive.</p><h3>Powering the Engine: LiipImagine Integration</h3><p>PGI doesn’t reinvent the wheel for image processing. Instead, it stands on the shoulders of a giant: <strong>LiipImagineBundle</strong>. By default, PGI can delegate the heavy lifting of resizing and filtering to LiipImagine, allowing you to leverage its full ecosystem.</p><p>One of the most powerful features of this synergy is the <strong>automatic conversion to modern formats like WebP</strong>. With just a few lines of configuration, you can ensure that every image served by PGI is not only perfectly sized but also perfectly compressed.</p><p><strong>Example Configuration:</strong></p><pre># config/packages/liip_imagine.yaml<br>liip_imagine:<br>    default_filter_set_settings:<br>        format: webp<br>    webp:<br>        generate: true<br><br># config/packages/progressive_image.yaml<br>progressive_image:<br>    image_configs:<br>        quality: 75<br>        post_processors:<br>            cwebp: { q: 30 }</pre><p>By using the liip_imagine decorator, PGI automatically routes image requests through LiipImagine&#39;s filter system. This means you can use all your existing Liip filters while benefiting from PGI&#39;s superior Twig syntax and Zero CLS features.</p><h3>Under the Hood: The Configuration That Makes It Possible</h3><p>One of the most praised aspects of PGI is its flexibility. While it works out-of-the-box, the real power lies in its configuration. Let’s break down the most important parts of progressive_image.yaml:</p><pre># config/packages/progressive_image.yaml<br>progressive_image:<br>    # 1. Responsive Strategy<br>    responsive_strategy:<br>        grid:<br>            framework: tailwind # or bootstrap, or custom<br>        ratios:<br>            landscape: &quot;16/9&quot;<br>            square: &quot;1/1&quot;<br>            hero: &quot;21/9&quot;<br><br>    # 2. Resolvers (Where are your images?)<br>    resolvers:<br>        public_files:<br>            type: &quot;filesystem&quot;<br>            roots: [ &#39;%kernel.project_dir%/public&#39; ]<br>        assets:<br>            type: &quot;asset_mapper&quot;<br><br>    # 3. Transparent HTML Caching<br>    image_cache_enabled: true<br>    image_cache_service: &quot;cache.app&quot;</pre><h4>1. Responsive Strategy</h4><p>This is the brain of PGI. By telling the bundle you use <strong>Tailwind</strong> or <strong>Bootstrap</strong>, it automatically knows the container widths for every breakpoint. When you say md:6, PGI looks up the md container width, divides it by 2 (6/12 columns), and generates the exact image size needed.</p><h4>2. Resolvers: File Freedom</h4><p>Whether you keep your images in the public/ folder or use the modern <strong>Symfony AssetMapper</strong>, PGI can find them. You can even define a chain resolver to look in multiple places. This is a lifesaver for projects transitioning to newer Symfony features.</p><h4>3. Performance First: HTML Caching</h4><p>Generating Blurhash and reading metadata requires CPU power. PGI solves this with <strong>transparent HTML caching</strong>. Once a component is rendered, the final HTML is stored in your cache. The next time someone visits the page, PGI serves the cached HTML instantly, skipping all PHP logic.</p><h3>Point of Interest (PoI) Cropping</h3><p>One of the coolest features is “Smart Cropping.” Instead of blindly cropping from the center, you can define a Point of Interest:</p><pre>&lt;twig:pgi:Image src=&quot;team.jpg&quot; pointInterest=&quot;75x25&quot; sizes=&quot;md:6@square&quot; /&gt;</pre><p>This ensures that the most important part of the image (like a person’s face) stays in the frame, regardless of whether it’s being cropped to a square, portrait, or landscape ratio.</p><h3>Why PGI Belongs in Your Next Project</h3><p>PGI isn’t just a wrapper; it’s a complete ecosystem for Symfony:</p><ul><li><strong>Zero Configuration:</strong> Install and it just works with Bootstrap or Tailwind.</li><li><strong>Automatic Generation:</strong> It generates all required sizes on the fly and caches them.</li><li><strong>LiipImagine Integration:</strong> It plays nice with existing tools if you need custom filters.</li><li><strong>Transparent Caching:</strong> It can cache the resulting HTML to avoid re-calculating metadata on every request.</li></ul><p>If you are building a modern Symfony application and care about SEO, UX, and your own sanity as a developer, PGI is the missing piece of the puzzle. It’s already powering high-performance sites like <a href="https://just6words.com/">just6words.com</a>, helping them achieve near-perfect PageSpeed scores.</p><p><strong>Ready to boost your PageSpeed?</strong> <a href="https://github.com/tito10047/progressive-image-bundle">Check out PGI on GitHub</a> and join the movement toward a faster, more stable web.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=28d2e5319883" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>