<?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 Fabien Potencier on Medium]]></title>
        <description><![CDATA[Stories by Fabien Potencier on Medium]]></description>
        <link>https://medium.com/@fabpot?source=rss-4ecc86a54ac5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*x_MP_nh-Ol92S-hq3zOedg.png</url>
            <title>Stories by Fabien Potencier on Medium</title>
            <link>https://medium.com/@fabpot?source=rss-4ecc86a54ac5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 06:19:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@fabpot/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[Week 1]]></title>
            <link>https://medium.com/@fabpot/week-1-49493b5d4611?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/49493b5d4611</guid>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Sat, 21 Mar 2020 09:57:30 GMT</pubDate>
            <atom:updated>2020-03-21T09:58:38.281Z</atom:updated>
            <content:encoded><![CDATA[<p>This is my first “lockdown” week-end after a week of confinement. I’m not alone. Most of us are confined now. Most of the world is confined or will be very soon.</p><p>I won’t go outside this week-end and that’s fine.</p><p>I’m lucky. I share my life with my wife and my two sons in my apartment in Lille, France. Hopefully, we’re not infected. Not yet. We’re now following the rules very strictly. To protect us, but more importantly, to protect everyone else. Let’s not be selfish.</p><p>In January and February, the weather was bad. It rained every single day. Or it seemed so. Since the beginning of the week, sun made a big come back. The sun taunts me. If you know me a little, you know that I would really like to go outside. Buy a book in my local bookstore, buy some groceries, find some new cheese to taste, bike to the butcher, jog in the biggest public park of the city. I would love to do all of these activities today. Like every “regular” Saturday. But for the next few weeks, my world will look different. I need to adapt. And that’s fine. I can certainly wait.</p><p>I’m lucky. I can work from home. My sons are 12 and 15, so they can do their homework on their own. Wonderful kids. They know how to spend their time. They read books, they watch some episodes of their favorite series on TV. They draw and they are talented. Don’t ask me to draw anything.</p><p>I’m lucky. I’m the CEO of two great companies. Symfony and Blackfire. Remote first companies. All employees are working remotely, from home. They live everywhere in the world. I’m proud of them. They are confined like everyone else. Some have kids at home. Some are anxious. We are all reading the news, trying to understand what’s going on; trying to imagine the impact of this “tornado”. We are also trying to keep working. As “usual”. Let’s be honest, maybe less than usual. That’s fine. The business is impacted. Some customers have already canceled their subscription. Very little new customers this week. That makes sense. At Symfony, we’re canceling or postponing all our worldwide conferences. At Blackfire, our marketing is mostly about sponsoring conferences. All our eggs in the same basket. How ironic. Everyone is on board to imagine our future. We have many ideas to reinvent ourselves. I’m blessed.</p><p>I’m lucky. I’m young-ish and I’m in good health. I want to help but I’m not a doctor. I’m trying to support my family and my employees the best I can. There is blood shortage in France, and in some other countries. I will donate my blood next week.</p><p>This is the week-end. I won’t go outside. I will probably read fiction books and code. I will cook for sure. As usual. But I will also take some time to dream. For a change. Or perhaps thinking about what’s next.</p><p>Be strong, stay safe.</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/week-1.html"><em>http://fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49493b5d4611" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Unpack the Packs]]></title>
            <link>https://medium.com/@fabpot/symfony-4-unpack-the-packs-a672d06850eb?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a672d06850eb</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[flex]]></category>
            <category><![CDATA[symfony4]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Thu, 04 Jan 2018 13:29:26 GMT</pubDate>
            <atom:updated>2018-01-21T09:17:43.050Z</atom:updated>
            <content:encoded><![CDATA[<p>We get a lot of positive feedback on Symfony 4. You love the new directory structure. You love the simplicity of using services without configuring anything. And you love the automation that Flex provides. It makes me happy and proud.</p><p>But one issue I hear sometimes is that it is more complex to start a new project. Most projects need many Symfony features. But new projects now have bare minimum dependencies when created via composer create-project symfony/skeleton. You need to explicitly add all the dependencies you want to depend on. Being explicit is great, but UX suffers. Ever tried to add profiler and didn&#39;t get timing info? Yup, symfony/stopwatch is optional, so you need to add it explicitly.</p><p>You loved the simplicity of starting a project with the Symfony Standard Edition. Is it nostalgia? Perhaps. Would it be possible to get the best of both world? Certainly! Read on.</p><p>First, let me recap some current available features:</p><ul><li>Any Composer package can have a related recipe that helps with auto-configuration (recipes are stored at symfony/recipes and symfony/recipes-contrib);</li><li>Symfony Packs are Composer metapackages that bundle several dependencies together to make your life easier (install symfony/debug-pack and get everything you need to debug a Symfony application).</li></ul><p>Symfony Packs are time savers, but they have one limitation: they mask the real dependencies. Let me explain with an example. Using symfony/orm-pack is a great way to get the most commonly needed Doctrine related packages and bundles. Run composer req symfony/orm-pack (or simply composer req orm) to get Doctrine core, the Doctrine bundle, and the Doctrine migrations bundle (everything configured thanks to some nice recipes).</p><p>But what if you want to remove one dependency that is included in the pack? Like the migrations bundle. You cannot remove it as the project’s composer.json file requires symfony/orm-pack, not the individual dependencies:</p><pre>diff --git a/composer.json b/composer.json<br>index e24f26b..5238f98 100644<br>--- a/composer.json<br>+++ b/composer.json<br>@@ -7,6 +7,7 @@<br>         &quot;symfony/flex&quot;: &quot;^1.0&quot;,<br>         &quot;symfony/framework-bundle&quot;: &quot;^4.0&quot;,<br>         &quot;symfony/lts&quot;: &quot;^4@dev&quot;,<br>+        &quot;symfony/orm-pack&quot;: &quot;^1.0&quot;,<br>         &quot;symfony/yaml&quot;: &quot;^4.0&quot;<br>     },<br>     &quot;require-dev&quot;: {</pre><p>Another example would be when you want to change a dependency constraint for a package coming from a pack.</p><p>You can of course require the individual dependencies, but for packs like debug or api, you would have to have a look at their composer.json on Github and do some copy/paste. Not ideal.</p><p>There is another way. Unpacking the pack. You can now unpack an already installed pack via the unpack command:</p><pre>composer unpack orm</pre><p>The command updates composer.json to remove the pack and replace it with the individual dependencies defined in the pack:</p><pre>diff --git a/composer.json b/composer.json<br>index 5238f98..b8c9794 100644<br>--- a/composer.json<br>+++ b/composer.json<br>@@ -3,11 +3,13 @@<br>     &quot;license&quot;: &quot;proprietary&quot;,<br>     &quot;require&quot;: {<br>         &quot;php&quot;: &quot;^7.1.3&quot;,<br>+        &quot;doctrine/doctrine-bundle&quot;: &quot;^1.6.10&quot;,<br>+        &quot;doctrine/doctrine-migrations-bundle&quot;: &quot;^1.3&quot;,<br>+        &quot;doctrine/orm&quot;: &quot;^2.5.11&quot;,<br>         &quot;symfony/console&quot;: &quot;^4.0&quot;,<br>         &quot;symfony/flex&quot;: &quot;^1.0&quot;,<br>         &quot;symfony/framework-bundle&quot;: &quot;^4.0&quot;,<br>         &quot;symfony/lts&quot;: &quot;^4@dev&quot;,<br>-        &quot;symfony/orm-pack&quot;: &quot;^1.0&quot;,<br>         &quot;symfony/yaml&quot;: &quot;^4.0&quot;<br>     },<br>     &quot;require-dev&quot;: {</pre><p>Tweaking the pack dependencies is now possible. Don’t want the migration bundles? Simple enough:</p><pre>composer rem migrations</pre><p>You can also unpack a pack at installation time via the --unpack flag. That flag tells Composer to add the dependencies of the pack in your composer.json instead of adding the pack package itself:</p><pre>composer req orm-pack --unpack</pre><p>Note that the unpack command and the --unpack flag only work for Symfony packs (the Composer package type must be symfony-pack). Any other dependencies are simply ignored and follow the standard Composer installation process.</p><p>That’s a great feature by itself and give you even more power when it comes to dependency management.</p><p>Now, you could create a “Symfony Standard Edition” pack and benefit from the new unpacking feature.</p><p>That would almost work. Except that the Symfony Standard Edition has dev dependencies that would not be installed by Composer. As you know, when adding a dependency, Composer will install any transitive dependencies from the require section, but it does not care about the ones defined under the require-dev section.</p><p>To get to the next level, and because you can now unpack a pack very easily, a Standard Edition can be re-created simply by having a new skeleton.</p><p>To demonstrate how that works, let’s take the brand new <a href="https://github.com/symfony/website-skeleton/blob/4.0/composer.json">“Symfony Website Skeleton”</a> as an example.</p><p>This new skeleton <em>almost</em> replicates Symfony Standard Edition’s dependencies:</p><pre>{<br>    &quot;name&quot;: &quot;symfony/website-skeleton&quot;,<br>    &quot;type&quot;: &quot;project&quot;,<br>    &quot;license&quot;: &quot;MIT&quot;,<br>    &quot;description&quot;: &quot;A skeleton to start a new Symfony website&quot;,<br>    &quot;require&quot;: {<br>        &quot;php&quot;: &quot;^7.1.3&quot;,<br>        &quot;ext-iconv&quot;: &quot;*&quot;,<br>        &quot;sensio/framework-extra-bundle&quot;: &quot;^5.1&quot;,<br>        &quot;symfony/asset&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/browser-kit&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/console&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/css-selector&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/debug-pack&quot;: &quot;*&quot;,<br>        &quot;symfony/expression-language&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/flex&quot;: &quot;^1.0&quot;,<br>        &quot;symfony/framework-bundle&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/form&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/lts&quot;: &quot;^4@dev&quot;,<br>        &quot;symfony/orm-pack&quot;: &quot;*&quot;,<br>        &quot;symfony/monolog-bundle&quot;: &quot;^3.1&quot;,<br>        &quot;symfony/process&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/security-bundle&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/serializer-pack&quot;: &quot;*&quot;,<br>        &quot;symfony/validator&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/swiftmailer-bundle&quot;: &quot;^3.1&quot;,<br>        &quot;symfony/web-link&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/webpack-encore-pack&quot;: &quot;*&quot;,<br>        &quot;symfony/yaml&quot;: &quot;^4.0&quot;<br>    },<br>    &quot;require-dev&quot;: {<br>        &quot;symfony/dotenv&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/maker-bundle&quot;: &quot;^1.0&quot;,<br>        &quot;symfony/phpunit-bridge&quot;: &quot;^4.0&quot;,<br>        &quot;symfony/profiler-pack&quot;: &quot;*&quot;<br>},<br>...</pre><p>Run composer create-project symfony/website-skeleton to start a new project. You get everything you need to get started fast. Use the unpack command if you need greater control over the added dependencies; unpack, remove, add as you see fit. You have full control. Note that if you unpack a dependency defined under require-dev, all its dependencies are added to the require-dev section as expected.</p><p>Like Silex ? Start with symfony/skeleton. Like the full-stack Symfony framework better? Start with symfony/website-skeleton. Then, be free to add or remove dependencies. Scale the way <em>you</em> want your project.</p><p>Packs makes it easy to create great skeletons. And unpack allows to keep the flexibility of being explicit and precise about the dependencies.</p><p>The new unpack feature opens a lot of possibilities and gives you even more flexibility and control on your project’s dependency management. Mind blowing if you ask me.</p><p>Happy Symfony!</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-unpack-the-packs.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a672d06850eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Performance out of the Box]]></title>
            <link>https://medium.com/@fabpot/symfony-4-performance-out-of-the-box-eddc0782916f?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/eddc0782916f</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony4]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Tue, 12 Dec 2017 15:54:28 GMT</pubDate>
            <atom:updated>2017-12-12T15:54:28.814Z</atom:updated>
            <content:encoded><![CDATA[<p>Performance is an interesting and sensitive topic. Suffice to say that most projects should not care too much; modern PHP frameworks are fast enough for most use cases and projects. And PHP 7 performance improvements help a lot as well. But people like to compare frameworks, and I guess performance is one way to do so.</p><p>What about Symfony 4? During its development cycle, we did some nice performance optimizations: mainly to improve the router and container speed. But several non-related changes in Symfony 4 also help with performance… Your mileage may vary depending on your specific project of course.</p><p>Synthetic benchmarks that were made to back pull requests that claimed to improve performance do not always convert to gain on real-world projects. Now that Symfony 4 is out, it’s time to test a full project. An “Hello World!” application benchmark is a good start as it helps understand <strong>the base performance of a framework</strong>. It helps understand the overhead added on top of PHP by your framework of choice. We spent so much time doing optimizations that I wanted to compare the out-of-the-box performance of a default Symfony Standard Edition project (based on Symfony 3) with the performance of a Symfony 4 project.</p><p>Benchmarking is a science and takes a lot of time. Luckily enough, and while I was procrastinating, someone did the work for me. The http://www.phpbenchmarks.com/en website has a great benchmark protocol and a great UI that let you browser and compare results easily.</p><p>According to those benchmarks, an “hello world” page on Symfony 4.0 is almost <strong>twice as fast</strong> as the same code using Symfony 3.4. You read that right. On PHP 7.2, Symfony 4.0 is twice as fast compared to Symfony 3.4.</p><p>There is also a benchmark for a more complex REST API application. Symfony 4 is again still much faster than 3.4.</p><p>Visit <a href="http://www.phpbenchmarks.com/en">http://www.phpbenchmarks.com/en</a> to get more numbers. Among other things, you will learn the following:</p><ul><li>Symfony on PHP 7.2 makes your code quite a bit faster than 7.1;</li><li>Symfony 2.3 is the <a href="http://www.phpbenchmarks.com/en/comparator/compare.html?components=symfony-2.3%7Esymfony-2.4%7Esymfony-2.5%7Esymfony-2.6%7Esymfony-2.7%7Esymfony-2.8%7Esymfony-3.0%7Esymfony-3.1%7Esymfony-3.2%7Esymfony-3.3%7Esymfony-3.4%7Esymfony-4.0&amp;benchmarkType=all&amp;benchmarkTools=apache-bench&amp;phpVersions=php-7.2&amp;concurrencies=">second fastest Symfony release</a> since 2.0</li><li>Symfony 3.4 is the slowest release since 2.0 (deprecated features are probably one of the reasons);</li><li>Symfony 4.0 is almost three times faster as Laravel 5.5.</li></ul><p>I would love to get some numbers for your application. Share them if you upgraded recently.</p><p>Enjoy using Symfony 4.0, the fastest Symfony ever released!</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-performance.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eddc0782916f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: An Update on Flex]]></title>
            <link>https://medium.com/@fabpot/symfony-4-an-update-on-flex-d12716ff8b92?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d12716ff8b92</guid>
            <category><![CDATA[flex]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony4]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Tue, 21 Nov 2017 08:11:01 GMT</pubDate>
            <atom:updated>2017-11-21T17:28:59.199Z</atom:updated>
            <content:encoded><![CDATA[<p>Symfony 4 is just around the corner. And Symfony Flex is one of the main selling points for the upgrade. Developers love the new philosophy. And a lot of changes happened since my last blog post. Let me recap the recent changes that you might not be aware of. Most of these changes were prompted by feedback from early adopters.</p><p>Using recipes from the <a href="https://github.com/symfony/recipes-contrib">contrib repository</a> has became easier. The first time you require a package for which a contrib recipe exists, Flex now asks you the permission to execute the recipe. It also lets you switch the “accept contrib recipes” flag for the project (so it does not ask the question again). Much better experience, and better discoverability.</p><p>One issue people have had a lot is recipes installed multiple-times. I thought Flex got you covered except under some rare circumstances, but apparently those rare conditions are a bit more frequent than I anticipated. So, instead of trying to make clever hooks into the Composer life-cycle to determine if a recipe should be applied or not, each project now has a symfony.lock file where Flex&#39;s state is stored (this file must be committed in the project&#39;s code repository). Problem solved. And that lock file opens up some nice opportunities... but that&#39;s for another iteration.</p><p>Makefile support proves to be a nightmare. Despite several patches to the recipes having some Makefile support (support for Windows and whatnot), it was a never ending battle. At the end of the day, we realize that people had wrong expectations about the Makefile, and that make is not so standard. Instead of fighting the tool, we decided to add symfony/console as a requirement. Done. Simple. Efficient. And yes, Makefile support was introduced just as a facade to the optional Symfony Console component. You can still use a Makefile for your project of course. And I still think that this is a good idea.</p><p>The minimum version supported by Flex is now PHP 7.0 instead of PHP 7.1 previously to let more people use Flex. It’s especially important for projects using Symfony 3.4, which is a long term support release. That will make the upgrade path to Symfony 4 smoother as well.</p><p>Having beta testers helped find bugs you would never have expected. When upgrading Flex, people had weird issues. That was because of how Composer plugins work. Some Flex classes are loaded early on by Composer. And if down the road, Flex is updated, you can have a situtation where a class from the newest version is mixed with classes from the old version. Not a good situation to be in. Now, Flex loads all its classes preemptively to be sure it is always in a consistent state.</p><p>In terms of features, Flex is now able to auto-register almost any bundle for which there are no recipes. And we added support for environment variables in PHPUnit configuration. Using Flex is also much faster as there are less roundtrips with the server (only one request per Composer session most of the time).</p><p>Regarding documentation, we have also started to document the new workflow with updates to the <a href="https://symfony.com/doc/4.0/setup/flex.html">upgrade tutorial</a> and the <a href="https://symfony.com/doc/4.0/best_practices/creating-the-project.html">best practices document</a>. They now take into account changes introduced by Flex. However, keep in mind that documentation updates are still on-going.</p><p>Last, but not least, the Symfony Flex Server has a new UI, which allows you to better discover available recipes, aliases, and packs.</p><p>Happy Flex!</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-flex-update.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d12716ff8b92" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Directory Structure Updates]]></title>
            <link>https://medium.com/@fabpot/symfony-4-directory-structure-updates-d8f4686546d5?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8f4686546d5</guid>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Mon, 03 Jul 2017 13:23:37 GMT</pubDate>
            <atom:updated>2017-07-21T08:48:27.123Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Update: </strong>This article has been updated to add missing steps.</p><p>After <a href="https://github.com/symfony/flex/issues/56">a long discussion in the community</a>, the directory structure has been slightly changed.</p><p>etc/ was renamed to config/, and web/ to public/. My blog posts about Symfony 4 have just been updated to reflect these changes.</p><p>If you already have a project using Symfony Flex, upgrading is as simple as:</p><ul><li>Renaming etc/ to config/;</li><li>Renaming web/ to public/;</li><li>Updating your web server configuration to take into account the new public/ directory;</li><li>Upgrading symfony/flex to the latest version;</li><li>Update composer.json to replace %WEB_DIR% to %PUBLIC_DIR%;</li><li>Update the content of src/Kernel.php with the one from the <a href="https://raw.githubusercontent.com/symfony/recipes/master/symfony/framework-bundle/3.3/src/Kernel.php">updated recipe</a>;</li><li>Done.</li></ul><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-directory-structure-updates.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8f4686546d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: A quick Demo]]></title>
            <link>https://medium.com/@fabpot/symfony-4-a-quick-demo-da7d32be323?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/da7d32be323</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[symfony4]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Tue, 02 May 2017 13:32:50 GMT</pubDate>
            <atom:updated>2017-09-21T11:57:44.341Z</atom:updated>
            <content:encoded><![CDATA[<p>Time to test Symfony 4… or at least let’s test the experience of developing Symfony 4 projects with Symfony 3.3. Keep in mind that all the tools are in preview mode. Features might evolve over time. I’m waiting for your feedback! The first stable version of Symfony Flex will not be released before Symfony 4 at the end of November 2017. It gives the community plenty of time to discuss the changes I have described in this series of blog posts.</p><h3>Creating a new Project</h3><p>The first step is to create a project. Currently, this needs to be done via composer create-project. We might release a tool to bootstrap a project faster.</p><p>Let’s go:</p><pre>composer create-project &quot;symfony/skeleton:^3.3&quot; demo<br>cd demo</pre><p>3.3 is the only currently available version and uses the yet-to-be-released Symfony 3.3. Versions like , 4.0, lts, or latest will be available later on (but not before the <a href="https://symfony.com/roadmap?version=4.0#checker">release of Symfony 4.0</a> of course).</p><p>The command downloads the <a href="https://github.com/symfony/skeleton">Symfony skeleton</a> which consists of just one composer.json file.</p><p>Then, it extracts the file into the demo directory and automatically runs composer install. symfony/flex is the first package to be installed so that it can hook into the Composer process. When Composer installs (or updates) other dependencies, Symfony Flex looks for an associated <em>recipe</em> on the Symfony Flex server, and executes it. You can see Symfony Flex in action via the logs it adds to the Composer output.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*bnwJiGQsoXIYMRIU.png" /></figure><p>When finished, you should see a “What’s next?” section that explains the possible next steps, like running make serve to start the PHP built-in web server. Before going further, go to the project&#39;s directory: cd demo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*OmIJulJkLYlv1bKW.png" /></figure><p>serve is one of the tasks added to the local Makefile, as described in the <a href="https://github.com/symfony/recipes/tree/master/symfony/framework-bundle/3.3">symfony/framework-bundle</a> recipe.</p><p>Note that some commands were automatically installed and run at the end of the process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*Vnq7YxNc-MRd_yGJ.png" /></figure><p>Again, those scripts were added to the project’s composer.json file as defined by the symfony/framework-bundle recipe. The second script did not run because the console tool (available via symfony/console) is not installed by default (we will see how to &quot;fix&quot; this issue later on).</p><p>Now is a good time to initialize Git:</p><pre>git init<br>git add .<br>git commit -m &quot;initial set of files&quot;</pre><p>Using git add . works well as Symfony took care of creating a &quot;good&quot; .gitignore file.</p><p>Remember that the skeleton only has one file, composer.json. Check the demo/ directory now; some more files have been created. Those files were added by Symfony Flex based on the installed packages, as described in recipes.</p><p>Let’s examine the directory structure now. Most files has been added because of the symfony/framework-bundle dependency.</p><p>The .env file defines the APP_ENV and APP_DEBUG environment variables:</p><pre>###&gt; symfony/framework-bundle ###<br>APP_ENV=dev<br>APP_DEBUG=1<br>APP_SECRET=ODtvoHW6pn3bE2rHgTa2MjkjwefzlsJH<br>###&lt; symfony/framework-bundle ###</pre><p>The comments allows Symfony Flex to “manage” this section. This is useful when those variables needs to be removed when the package is removed. If you remove the comments, Symfony Flex will not be able to automatically manage these variables anymore. Have a look at .gitignore for a similar example.</p><p>If you’re curious, check public/index.php, the new web front controller.</p><p>The most interesting files are under config/. The main entry points are the empty container.yaml and routing.yaml files; this is where you can add services, parameters, and routes for your project. A default configuration has been installed as well for symfony/framework-bundle under config/packages/. Feel free to tweak installed configuration files or add more for your own needs.</p><p>Last, but not least, FrameworkBundle is now registered in bundles.php:</p><pre>return [<br>    &#39;Symfony\Bundle\FrameworkBundle\FrameworkBundle&#39; =&gt; [&#39;all&#39; =&gt; true],<br>];</pre><p>Even if a bundle does not have a recipe, Symfony detects Composer packages with the symfony-bundle type and automatically enable them for all environments. This avoids the creation of recipes when registration is just a matter of enabling the bundle.</p><p>The src/ directory is where you can store your PHP classes. Under the App\ namespace as registered in composer.json. Note that this is where Kernel.php was also installed as App\Kernel.</p><p>Now, it is time to install some new dependencies via Composer. Let’s start by adding a more powerful web server for your project:</p><pre>composer req webserver</pre><p>And install Symfony console support via:</p><pre>composer req cli</pre><p><strong>Note</strong>: req is a shortcut for require (the Composer CLI supports any shortcut that is not ambiguous; use rem to remove a Package).</p><p>webserver is an <strong>alias</strong> for symfony/web-server-bundle, and cli is an alias for symfony/console. That works because Symfony Flex knows how to convert those aliases into full package names: cli is equivalent to console, which is equivalent to symfony/console. The symfony/ prefix is always optional. Try composer req workflow or composer req ldap. web-server-bundle is too cumbersome, so use webserver or just server.</p><p>For Symfony dependencies, Symfony Flex also recognizes a few more versions than the usual Composer ones, mainly next, previous, lts, and stable (they don&#39;t all work yet though).</p><pre>composer req cli:next</pre><p>After executing composer req cli, notice how the assets:install command automatically ran. The bin/console file has also been added to your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*HadaKQeD33elCFmu.png" /></figure><p>Aliases work when removing dependency as well:</p><pre>composer rem cli</pre><p>… which also removes the bin/console binary (for fun, try this: composer rem framework-bundle).</p><p>Remember I wrote about the developer experience when installing a Symfony bundle? Let’s go wild and install something really “complex” like an admin generator based on Doctrine. How many steps to make it work? It might be fewer than you expect, and definitely more fun.</p><p>First, let’s install <a href="https://github.com/javiereguiluz/EasyAdminBundle">EasyAdminBundle</a>:</p><pre>composer req admin</pre><p>Besides installing the admin generator bundle, it also installs all its transitive dependencies and auto-configures them all: TwigBundle, SecurityBundle, FrameworkExtraBundle, and DoctrineBundle.</p><p>admin is a &quot;generic&quot; word. This is why I wrote about Symfony Flex recipes being opinionated. There can only be one package aliased to admin. orm is another generic word that is currently aliased to the Doctrine ORM.</p><p>Run the PHP built-in web-server via make serve or bin/console server:start and go to http://localhost:8000/admin/. You should get an error as no Doctrine entities exist yet. Let&#39;s create one in src/Entity/Product.php:</p><pre>&lt;?php</pre><pre>namespace App\Entity;</pre><pre>use Doctrine\ORM\Mapping as ORM;</pre><pre>/**<br> * @ORM\Entity<br> * @ORM\Table(name=&quot;product&quot;)<br> */<br>class Product {<br>    /**<br>     * @ORM\Column(type=&quot;integer&quot;)<br>     * @ORM\Id<br>     * @ORM\GeneratedValue(strategy=&quot;AUTO&quot;)<br>     */<br>    public $id;</pre><pre>    /**<br>     * @ORM\Column(type=&quot;string&quot;, length=100)<br>     */<br>    public $name;</pre><pre>    /**<br>     * @ORM\Column(type=&quot;decimal&quot;, scale=2)<br>     */<br>    public $price;</pre><pre>    /**<br>     * @ORM\Column(type=&quot;text&quot;)<br>     */<br>    public $description;<br>}</pre><p>Tweak the database configuration in .env:</p><pre>###&gt; doctrine/doctrine-bundle ###<br>DATABASE_URL=mysql://root@127.0.0.1:3306/symfony?charset=utf8mb4<br>###&lt; doctrine/doctrine-bundle ###</pre><p>Run the following commands to initialize the database:</p><pre>./bin/console doctrine:database:create<br>./bin/console doctrine:schema:update --force</pre><p>Finally, add the Product entity to the list of entities managed by the admin generator (config/packages/easy_admin.yaml):</p><pre>easy_admin:<br>    entities:<br>        - App\Entity\Product</pre><p>Try http://localhost:8000/admin/ again. If everything worked well, you should be able to manage products.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*urJ3yFhS1j25YOiu.png" /></figure><p>Instead of installing an admin generator, have a look at this small screencast where I’m using the api alias to bootstrap an API project quickly and easily:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fo9N1nOYfAl4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do9N1nOYfAl4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fo9N1nOYfAl4%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c7daf0fedd9c799cd84feeefbf4db05/href">https://medium.com/media/5c7daf0fedd9c799cd84feeefbf4db05/href</a></iframe><p>Here are some nice aliases you can try:</p><ul><li>sec-checker to install the SensioLabs Security Checker;</li><li>req-checker to install the Symfony requirements checks;</li><li>log to install MonologBundle and all its dependencies;</li><li>template for Twig;</li><li>mailer for Swiftmailer;</li><li>profiler for the profiler;</li><li>… you get the point :)</li></ul><p>As symfony/symfony is not required anymore, you get more fine-grained dependencies, but it might be cumbersome to install each Symfony component one by one. To ease the pain, I&#39;m experimenting with a new concept: &quot;packs&quot;. A pack is nothing more than a regular Git repository registered on Composer that contains a composer.json that references a set of related packages. As an example, I have created a <a href="https://github.com/symfony/debug-pack">debug-pack pack</a> that can be installed via composer req debug-pack. Have a look at the <a href="https://github.com/symfony/orm-pack">ORM pack</a> or the <a href="https://github.com/api-platform/api-pack">API pack</a>. Imagine a web-pack that references nothing in composer.json but is associated with a recipe that installs a set of default files under public/ like favicons, a robots.txt, and so on. Nice? Imagine the same for Travis, Blackfire, or Docker. Or a pack that installs the exact same dependencies as the current Symfony Standard Edition? Your imagination is the limit. Compose your applications with off-the-shelf packages, packs, and their associated recipes.</p><p>Symfony Flex enables <strong>distribution composition instead of inheritance</strong>. The new way is easier, more flexible, and more powerful at the same time.</p><p>The first version of the Symfony Flex server is quite simple, but over time, more features will be implemented.</p><p>Now, it is probably time for you to write some code. What about some controllers and templates? Hold on. Even if you can do what you are used to, Symfony 3.3 and Symfony 4.0 proposes a much smoother experience that you might like better. This is a great topic for my next post about Symfony 4.</p><p>Remember that the recipes repositories at <a href="https://github.com/symfony/recipes">https://github.com/symfony/recipes</a> and <a href="https://github.com/symfony/recipes-contrib">https://github.com/symfony/recipes-contrib</a> are also public now. Feel free to look around. And keep in mind that what you see is experimental. Current choices might change.</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-demo.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da7d32be323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4 : A small screencast…]]></title>
            <link>https://medium.com/@fabpot/symfony-4-a-small-screencast-cf6511823f?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf6511823f</guid>
            <category><![CDATA[symfony4]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Fri, 28 Apr 2017 20:17:50 GMT</pubDate>
            <atom:updated>2017-04-29T17:58:30.997Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, I published the repositories for the Symfony recipes. The main repository is at <a href="https://github.com/symfony/recipes">https://github.com/symfony/recipes</a>, and the contrib one at <a href="https://github.com/symfony/recipes-contrib">https://github.com/symfony/recipes-contrib</a>. Both are public. Additions and feedback welcomed.</p><p>Today, I want to share with you a small recording I have just made that shows how it feels to use Symfony Flex when creating a new project. It also demonstrates how to add more dependencies and illustrate the auto-configuration part I have written about in my previous blogs posts about Symfony 4. Instead of creating a classical website, this video levers the API Platform recipe recently added to create an API in just a few commands.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fo9N1nOYfAl4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Do9N1nOYfAl4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fo9N1nOYfAl4%2Fhqdefault.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/5c7daf0fedd9c799cd84feeefbf4db05/href">https://medium.com/media/5c7daf0fedd9c799cd84feeefbf4db05/href</a></iframe><p>Exciting, right?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf6511823f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Contributing Recipes]]></title>
            <link>https://medium.com/@fabpot/symfony-4-contributing-recipes-2f489dc6f645?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f489dc6f645</guid>
            <category><![CDATA[symfony4]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[composer]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Tue, 18 Apr 2017 14:18:23 GMT</pubDate>
            <atom:updated>2017-05-08T14:10:44.448Z</atom:updated>
            <content:encoded><![CDATA[<p>Symfony Flex is not Open-Sourced yet, but I can already feel the excitement in the community. I have also received some feedback via Twitter, Slack, and email during the last few days. That makes me really happy!</p><p>Everybody knows that I like to tease. Trying to build the momentum on something you have been working on for months feels great. But the reality is a bit more complex: I am still working on the first MVP of the infrastructure needed to support Symfony Flex. To be honest, I’m probably working on something that is a bit more than just an MVP.</p><p>The good news is that I’m almost there. The bad news is that some feedback made me realize that some features I had on my todo list for later need to be part of the first version. You know, that “one more feature” that will make Symfony Flex the next killer application for the Symfony community.</p><p>People are worried about the opinionated recipe repository. Keep in mind that one of the main goals of Symfony Flex is to automate your day-to-day workflow for the happy path.</p><p>First, I want to reiterate that a package does not need to have a recipe to be installed. The good old way of registering bundles manually and copy/pasting some default configuration will still work fine… which is what everybody has been doing for years. In other words, everything will be at least as easy to install as it is now.</p><p>Then, for several reasons I explained in my previous post, I won’t change my mind about the official repository being opinionated. I talk to a lot of developers and companies using Symfony, and many want “us” to make choices for them. They don’t want to test dozens of bundles to make an informed choice.</p><p>Finally, I need to reveal one more recipe configuration option that I did not mention yet: <em>aliases</em>. Instead of using the regular Composer package name, a recipe can list alternative shorter names. For instance, use composer req cli instead of composer req symfony/console. You can imagine packages willing to reserve the admin, api, or orm aliases. And of course, each alias can only be linked to one Composer package.</p><p>Choices are good.</p><p>But what about having another recipe repository along side the main one? Well, that feature was on my todo list for a future version. But I have decided to include it now. For the first version. And I like it a lot.</p><p>Let’s dive into the Symfony Flex recipe repositories. Instead of having just one repository, Symfony Flex supports two.</p><p>Here is how it works:</p><ul><li>The “main” official repository, hosted at <a href="https://github.com/symfony/recipes">https://github.com/symfony/recipes</a> will be opinionated. Submissions will be reviewed carefully. They will need approval from the Symfony core team (like pull requests on the main symfony/symfony repository). We want the utmost quality and the <em>best</em> developer experience.</li><li>The “contrib” repository, hosted at <a href="https://github.com/symfony/recipes-contrib">https://github.com/symfony/recipes-contrib</a> will not be opinionated. Curated by the community at large, most submissions will be accepted.</li></ul><p>Other than the rules to accept submissions, the “main” and the “contrib” repositories work in the exact same way, except for the following differences:</p><ul><li>Only the “main” repository can define aliases (that makes sense I suppose);</li><li>By default, Symfony Flex only searches recipes in the “main” repository. Using the “contrib” repository is <em>opt-in</em>. Enable it by executing composer config extra.symfony.allow-contrib true.</li></ul><p>And packages can be promoted from the “contrib” repository to the “main” one as well.</p><p>To maintain a high level of quality, I have also developed a set of validation rules for recipes. When you submit a pull request on both repositories, the Symfony Flex server runs a series of checks to ensure that your changes are valid. Basic checks like validating the existence of the package on Packagist. And more interesting ones like checking that two packages do not define the same alias.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*7CnR1c9jNhSXrx3M.png" /></figure><p>But more interesting, a dedicated staging Flex Server is built for every pull request. That allows anyone to test the changes before they are merged into the master/production branch of a repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*d3lZLq85WolwthZn.png" /></figure><p>For instance, if you submit a pull request (number 42) on the “contrib” repository that adds a recipe for package “foo/bar”, install your new package by defining the SYMFONY_ENDPOINT environment variable:</p><pre>SYMFONY_ENDPOINT=<a href="https://symfony.sh/r/contrib/42">https://symfony.sh/r/contrib/42</a> composer req foo/bar</pre><p>If changes are submitted for “core” packages (like in symfony/framework-bundle), using the environment variable even works with composer create-project:</p><pre>SYMFONY_ENDPOINT=<a href="https://symfony.sh/r/main/42">https://symfony.sh/r/main/42</a> composer create-project symfony/skeleton demo</pre><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-contributing-recipes.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f489dc6f645" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Automate your Workflow]]></title>
            <link>https://medium.com/@fabpot/symfony-4-automate-your-workflow-fbbf609b5a1d?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbbf609b5a1d</guid>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[symfony4]]></category>
            <category><![CDATA[composer]]></category>
            <category><![CDATA[php]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Thu, 13 Apr 2017 14:00:56 GMT</pubDate>
            <atom:updated>2017-09-21T11:49:35.254Z</atom:updated>
            <content:encoded><![CDATA[<p>Symfony 4’s most “innovative” feature is the way it drives the day-to-day application management. No more tedious copy/paste from README files. No more boilerplate code. Automation to the max. On a curated list of Composer packages.</p><h3>Symfony Flex</h3><p>Symfony 4 is powered by Symfony Flex, a deceptively simple but powerful Composer plugin. The <a href="https://github.com/symfony/skeleton">default Symfony skeleton</a> only lists two main dependencies: symfony/flex and symfony/framework-bundle. Everything else is optional.</p><p>As you can imagine, most projects need more than FrameworkBundle. And installing and configuring all packages and bundles by hand is error-prone, tedious, and just plain boring. Even for the few dependencies that Symfony Standard Edition depends on.</p><p>This is where Symfony Flex shines.</p><p>When you install a Composer package, Flex hooks into the installation process to automate its integration into your project via pre-defined and community-driven recipes. It works for any Composer packages, not just Symfony bundles. If a recipe does not exist, you can still configure it the old way, like you currently do.</p><p>Take sensiolabs/security-checker as an example. It works for any PHP projects. But when installed on a project using Symfony Flex, it knows how to run the checker whenever you run composer install.</p><p>The automation is implemented in a recipe that has a JSON manifest that describes how to integrate the package into a Symfony application. Here is the one for sensiolabs/security-checker:</p><pre>{<br>    &quot;copy-from-recipe&quot;: {<br>        &quot;config/&quot;: &quot;%CONFIG_DIR%/&quot;<br>    },<br>    &quot;composer-scripts&quot;: {<br>        &quot;vendor/bin/security-checker security:check&quot;: &quot;php-script&quot;<br>    }<br>}</pre><p>Flex currently implements 9 “configurators” that helps automate the integration of any PHP package into a Symfony application: copy-from-recipe, copy-from-package, bundles, env, container, makefile, composer-scripts, gitignore, and post-install-output.</p><h3>Bundles</h3><p>The bundles configurator enables bundles in your project by adding them to the bundles.php file (and it removes them when you uninstall the dependency):</p><pre>{<br>    &quot;bundles&quot;: {<br>        &quot;Symfony\\Bundle\\DebugBundle\\DebugBundle&quot;: [&quot;dev&quot;, &quot;test&quot;],<br>         &quot;Symfony\\Bundle\\MonologBundle\\MonologBundle&quot;: [&quot;all&quot;]<br>    }<br>}</pre><h3>Configuration</h3><p>Configuration can be added via the copy-from-recipe and copy-from-package configurators: the former copies files from the recipe while the later copies files from the Composer package itself.</p><pre>{<br>    &quot;copy-from-package&quot;: {<br>        &quot;bin/check.php&quot;: &quot;%BIN_DIR%/check.php&quot;<br>    }, <br>    &quot;copy-from-recipe&quot;: {<br>        &quot;config/&quot;: &quot;%CONFIG_DIR%/&quot;,<br>        &quot;src/&quot;: &quot;%SRC_DIR%/&quot;<br>    }<br>}</pre><h3>Environment Variables</h3><p>The env configurator knows how to add environment variables to the project&#39;s .env and .env.dist files (and removes them when uninstalling the dependency):</p><pre>{<br>    &quot;env&quot;: {<br>        &quot;APP_ENV&quot;: &quot;dev&quot;,<br>        &quot;APP_DEBUG&quot;: &quot;1&quot;<br>    }<br>}</pre><h3>Makefile Tasks</h3><p>The makefile configurator adds new tasks to the project&#39;s Makefile (and removes them when uninstalling the dependency). Unlike other configurators, there is no entry in the manifest.json. Just define tasks in a Makefile file:</p><pre>cache-clear:<br>    <a href="http://twitter.com/test">@test</a> -f bin/console &amp;&amp; bin/console cache:clear --no-warmup || rm -rf var/cache/*<br>.PHONY: cache-clear</pre><pre>cache-warmup: cache-clear<br>    <a href="http://twitter.com/test">@test</a> -f bin/console &amp;&amp; bin/console cache:warmup || echo &quot;cannot warmup the cache (needs symfony/console)&quot;<br>.PHONY: cache-warmup</pre><p><em>Note</em>: A previous version of this blog post described a previous version where the post install output was defined in the manifest.json file.</p><h3>Composer Scripts</h3><p>The composer.json file defined in symfony/skeleton contains the following snippet:</p><pre>{<br>    &quot;scripts&quot;: {<br>        &quot;auto-scripts&quot;: [ ],<br>        &quot;post-install-cmd&quot;: [ &quot;@auto-scripts&quot; ],<br>        &quot;post-update-cmd&quot;: [ &quot;@auto-scripts&quot; ]<br>    }<br>}</pre><p>The composer-scripts configurator manages the special @auto-scripts section by adding commands and scripts defined in recipes. Those are automatically run on composer install and composer update:</p><pre>{<br>    &quot;composer-scripts&quot;: {<br>        &quot;assets:install --symlink --relative %PUBLIC_DIR%&quot;: &quot;symfony-cmd&quot;<br>    }<br>}</pre><h3>.gitignore</h3><p>The .gitignore configurator adds patterns to the .gitignore file. And like for the other configurators, it knows how to clean up when you remove a package:</p><pre>{<br>    &quot;gitignore&quot;: [<br>        &quot;/phpunit.xml&quot;<br>    ]<br>}</pre><h3>post-install-output</h3><p>If you want to display some next step actions when a package is installed, list them via the post-install-output configurator. Like for the Makefile, the output must be defined in a post-install.txt:</p><pre>Execute &lt;fg=blue&gt;make serve&lt;/&gt; to run your application.</pre><p><em>Note</em>: A previous version of this blog post described a previous version where<br>the post install output was defined in the `manifest.json` file.</p><h3>Full Example</h3><p>The most “complex” manifest is currently the one for symfony/framework-bundle and reads as follows:</p><pre>{<br>    &quot;bundles&quot;: {<br>        &quot;Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle&quot;: [&quot;all&quot;]<br>    },<br>    &quot;copy-from-recipe&quot;: {<br>        &quot;config/&quot;: &quot;%CONFIG_DIR%/&quot;,<br>        &quot;public/&quot;: &quot;%PUBLIC_DIR%/&quot;,<br>        &quot;src/&quot;: &quot;%SRC_DIR%/&quot;<br>    },<br>    &quot;composer-scripts&quot;: {<br>        &quot;make cache-warmup&quot;: &quot;script&quot;,<br>        &quot;assets:install --symlink --relative %PUBLIC_DIR%&quot;: &quot;symfony-cmd&quot;<br>    },<br>    &quot;env&quot;: {<br>        &quot;APP_ENV&quot;: &quot;dev&quot;,<br>        &quot;APP_DEBUG&quot;: &quot;1&quot;,<br>        &quot;APP_SECRET&quot;: &quot;%generate(secret)%&quot;<br>    },<br>    &quot;gitignore&quot;: [<br>        &quot;.env&quot;,<br>        &quot;/public/bundles/&quot;,<br>        &quot;/var/&quot;,<br>        &quot;/vendor/&quot;<br>    ]<br>}</pre><p>That’s all. I have yet to find a case not covered by this small set of configurators. Note that I might remove the container one as it is not used anymore in the current set of recipes I have written so far.</p><h3>An Opinionated Repository</h3><p>The Symfony Flex recipe repository will be opinionated. The developer is free to use any combinations of packages, but to be able to provide a good sensible configuration, we need to make choices. We won’t be able to support all bundles, only a curated set of them. Which is probably a good thing as well.</p><p>Symfony doesn’t make choices for you. And that makes sense. You know what you need for your project. But with more than 3000 bundles to choose from, selecting the right bundle from the ecosystem is far from being easy for beginners. Want an admin generator? Currently, you need to choose between 26 different ones. And several are quite popular. Which one should I use?</p><p>Compare that to symfony1, where the admin generator was built-in. This is just one example. Have a look at the number of Blog bundles, or API ones. The great news is that the Symfony community is hard at work.</p><p>Along the years, Symfony became a very low-level framework, without batteries included. Now that Symfony gives us a very powerful platform to work with, I think we can work on being more opinionated again.</p><p>We should be giving more exposure to good bundles. In order to do that, we would first need to define what “good” means. I can imagine some simple rules like the license, or the number of opened bugs vs activity on the Git repository, the amount of documentation, the number of contributors, whether it is compatible with a large set of Symfony versions, and so on.</p><p>And of course, any bundle can still be installed the old way, without auto-configuration.</p><h3>The Symfony Flex Server</h3><p>Besides being a Composer plugin, Symfony Flex also communicates with an HTTP server to get up-to-date information about package recipes, aliases, and more.</p><p>Eager to try out Symfony Flex? Well, I will push everything to Github just in time for the next blog post.</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-workflow-automation.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbbf609b5a1d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony 4: Directory Structure]]></title>
            <link>https://medium.com/@fabpot/symfony-4-directory-structure-5b84bd1ce65a?source=rss-4ecc86a54ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b84bd1ce65a</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[symfony4]]></category>
            <dc:creator><![CDATA[Fabien Potencier]]></dc:creator>
            <pubDate>Mon, 10 Apr 2017 16:17:46 GMT</pubDate>
            <atom:updated>2017-07-03T13:08:58.716Z</atom:updated>
            <content:encoded><![CDATA[<p>Symfony 3 came with a slightly different directory structure than Symfony 2. Symfony 4 will also come with a reworked directory structure. Mostly incremental adjustments to support new features and best practices.</p><p>The Symfony 3 <a href="https://github.com/symfony/symfony-standard/issues/584#issuecomment-23148928">directory structure</a> introduced a more standard Unix-like directory structure, with less sub-directories. Symfony 4 keeps going in that direction.</p><p>Using well-known directory names helps. Using bin/, src/, or var/ was a great step forward. Symfony 4 adds etc/ in place of app/. It was proposed for Symfony 3 but rejected for reasons that don&#39;t hold anymore.</p><p><strong>Update:</strong> The etc/ has been changed to config/ after a long discussion with the community. The web/ directory has also been changed to public/. The blog posts about Symfony 4 have been updated to reflect these changes.</p><h3>Tests under tests/</h3><p>Tests move to a top-level tests/ directory. It was proposed before, it just makes sense now that we have bundle-less applications. It also allows to declare a specific test namespace for autoloading:</p><pre>{<br>    &quot;autoload&quot;: { &quot;psr-4&quot;: { &quot;App\\&quot;: &quot;src/&quot; } },<br>    &quot;autoload-dev&quot;: { &quot;psr-4&quot;: { &quot;App\\Tests\\&quot;: &quot;tests/&quot; } }<br>}</pre><h3>Templates under templates/</h3><p>Templates become first-class citizens via a new top-level templates/ directory. Would tpl make more sense compared to the other short 3-letter directory names?</p><p>Why not views? views was the original name I chose very early on because it was shorter than templates. It was a mistake as View is a concept by itself. Fixed, finally.</p><p>Having templates at the root level also makes working with web designers easier. And this directory is only created when you install Twig.</p><p>Moving templates allows to reserve src/ for PHP classes only, no more resources. Another consequence of being bundle-less.</p><h3>Configuration under config/</h3><p>The new config/ directory is the equivalent of the current app/config/ directory. But with a very different layout. parameters.yml and parameters.yml.dist are gone.</p><p>The main entry point for the container is an empty container.yaml that you can use to define your own services and parameters. Configuration for bundles that you install via Composer are stored as <strong>individual</strong> files. One file per bundle and per environment. The same goes for the routing configuration. That&#39;s a soft requirement for auto-configuration, but allows for a better file organization.</p><p>Configuration files can be written in PHP, XML, or YAML as before. The only difference being the usage of the standard .yaml extension instead of the current .yml one.</p><p>One major change is the introduction of a bundles.php file where installed bundles are referenced.</p><p>One file per bundle and bundles.php are the two core concepts that enables Symfony to automatically manage your bundles and their configurations.</p><h3>Source Code under src/</h3><p>The Kernel class has been moved to src/, where it belongs. The content is very different from the one in Symfony 2. First, it uses the MicroKernelTrait trait. Then, it implements the logic to load the bundles from bundles.php and to read the various bundle configuration files. The logic works as of Symfony 3.3. For instance, the code that loads the container configuration files reads as follow:</p><pre>protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) {<br>    $confDir = dirname(__DIR__).&#39;/config&#39;; $loader-&gt;import($confDir.&#39;/packages/*&#39;.self::CONFIG_EXTS, &#39;glob&#39;);<br>    if (is_dir($confDir.&#39;/packages/&#39;.$this-&gt;getEnvironment())) {<br>        $loader-&gt;import($confDir.&#39;/packages/&#39;.$this-&gt;getEnvironment().&#39;/**/*&#39;.self::CONFIG_EXTS, &#39;glob&#39;);<br>    }<br>    $loader-&gt;import($confDir.&#39;/container&#39;.self::CONFIG_EXTS, &#39;glob&#39;);<br>} </pre><h3>Temporary files under var/</h3><p>var/ is very similar to Symfony 3, with some minor tweaks in the best practices.</p><p>var/cache/ should now only be used to store long term cached contents like compiled container files, compiled translations, or Doctrine proxies. No temporary files. Basically, anything stored under var/cache should have a warmup class able to generate the cache files. Files that should never be updated after deployment to allow for read-only filesystems.</p><p>What about temporary files then? Use another directory like var/tmp/. Or just the standard Unix /tmp directory.</p><p>If you follow this best practice, we will be able to guarantee a read-only /var/cache directory at some point. Having read-only directories is a requirement of some hosting platforms like Heroku or SensioCloud and helps scale an application. Probably not for Symfony 4.0 though.</p><h3>Web files under public/</h3><p>I have already mentioned the single web front controller under public/. Almost all the other files were removed. No config.php. No .htaccess. No favicon.ico or apple-touch-icon.png. Not even robots.txt. Not all projects need those files. If you want skeletons for those files, I got you covered of course.</p><h3>Everything is optional</h3><p>One difference with Symfony 3 is that all first-level directories are optional. Don’t use templates for you API? No need to create a templates/ directory. Directories are created on-demand anyway.</p><p>When using Composer to add a new bundle, Symfony 4 levers this new directory structure to automatically register the bundle in bundles.php, copy some sensible configuration under config/, and much more. What else you ask? Great topic for the next post.</p><p><em>Originally published at </em><a href="http://fabien.potencier.org/symfony4-directory-structure.html"><em>fabien.potencier.org</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b84bd1ce65a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>