<?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 Jacob Tobiasz on Medium]]></title>
        <description><![CDATA[Stories by Jacob Tobiasz on Medium]]></description>
        <link>https://medium.com/@jakubtobiasz?source=rss-f746aad858ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fxiKYzAUER45fFCWorfCIw@2x.jpeg</url>
            <title>Stories by Jacob Tobiasz on Medium</title>
            <link>https://medium.com/@jakubtobiasz?source=rss-f746aad858ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:58:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jakubtobiasz/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[Mark Your Classes As Final Like A Pro]]></title>
            <link>https://medium.com/alphpaca/mark-your-classes-as-final-like-a-pro-ae7a5de32a74?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae7a5de32a74</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Thu, 15 Dec 2022 16:45:22 GMT</pubDate>
            <atom:updated>2022-12-23T19:44:09.190Z</atom:updated>
            <content:encoded><![CDATA[<h3>Final Classes = Instant Code Quality Boost</h3><p>I feel that final keyword is some kind of bone of contention in our PHP community. Let’s dive into this dispute, and try to figure out what might be a better choice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*ZMgAIr-4vHPo9_MC0D6zQA.png" /></figure><h3>What Is A Final Keyword?</h3><p>When we mark any class as final, we prohibit other classes to extend it. If you never used this feature before, you might wonder why we might want to prevent inheritance. But before we explain some things, let’s learn <strong>how to not use final keyword</strong>.</p><h3>How To Not Use Final Keyword</h3><p>We can mark almost every class as final, but there are cases when we shouldn’t or can’t do it. What are these cases?</p><ul><li>There is at least one public method not covered by any of the implemented interfaces. <strong>Why?</strong> We make it impossible to decorate such method.</li><li>Your class is an entity (at least Doctrine’s entity). <strong>Why?</strong> Doctrine has problems with handling entities marked as final.</li></ul><p>And, that’s all (if you ask me). All other cases (despite those that I forgot about) can be handled with final keyword. So, why we want to use final keyword?</p><h3>Benefits Of Using Final Keyword</h3><p>We may consider a final keyword as a trap card. You extend a class, and boom, error. If you would like to use any behavior from this class, compose a new one. If you’re trying to extend its behavior, use the decorator pattern.</p><ul><li>We force a composition over inheritance approach. <strong>Why?</strong> You can’t extend = you’re forced to use composition.</li><li>We force Open-Closed principle. <strong>Why?</strong> You can extend what happens before or after, but you can’t modify the original behavior.</li><li>We force a developer to think about public API. <strong>Why?</strong> Final keyword works great only with interfaces.</li></ul><h3>Any Disadvantages?</h3><p>I’m uncertain if I can count is as a disadvantage, but it takes time to change the way how you think. For the first time it might be unnatural to compose a new class from the existing ones, instead just extend other class.</p><h3>So, Do I Really Need Final Keyword?</h3><p>As long as you have an interface for every public method, and you code using good practices, starting using final keyword might be a transparent change for you. The most important is to take this decision on the project-level, and make sure every team member understands why you use final keyword. You can achieve the same results without final keyword, I treat it more like a “static-analysis” than the feature I couldn’t live without.</p><p>Thanks for reading, and see you in the next articles soon. As always, I am reminding that you can find me here:</p><p>Twitter 👉🏼 <a href="https://twitter.com/jakub_tobiasz">https://twitter.com/jakub_tobiasz</a></p><p>Mastodon 👉🏼 <a href="https://phpc.social/web/@jakubtobiasz">https://phpc.social/web/@jakubtobiasz</a></p><p>GitHub 👉🏼 <a href="https://github.com/jakubtobiasz">https://github.com/jakubtobiasz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae7a5de32a74" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/mark-your-classes-as-final-like-a-pro-ae7a5de32a74">Mark Your Classes As Final Like A Pro</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop overcreating interfaces in PHP]]></title>
            <link>https://medium.com/alphpaca/stop-overusing-interfaces-in-php-25c9b5c4b65d?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/25c9b5c4b65d</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 13:31:36 GMT</pubDate>
            <atom:updated>2022-12-09T17:36:59.336Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JlrPtUY1nnHOkEdx47vSTA@2x.jpeg" /><figcaption>Photo by Elena Mozhvilo on Unsplash</figcaption></figure><h4>Update 09–12–2022</h4><p>I decided to include this edit note, as after some discussions I understood the key thought might not be interpreted as I intended.</p><p>This article isn’t about using interfaces, but rather about creating them (that’s why I changed the title from “overusing” to “overcreating”). If you don’t have an advanced architecture, where your goal is to decouple from the framework or other libraries, it might be a better idea to use the external interface directly, instead of creating your own and extending the external one. Then the contract is preserved, but in your code you can use your class directly.</p><p>On my journeys, I usually scroll my Twitter feed, and my journey to Wrocław wasn’t different. The following tweet came across:</p><h3>Matt Stauffer on Twitter: &quot;🌶️ PHP opinion:Most interfaces in PHP code are completely useless, and actually just add unnecessary complication that makes the code harder to understand, especially for newcomers.#yagni / Twitter&quot;</h3><p>🌶️ PHP opinion:Most interfaces in PHP code are completely useless, and actually just add unnecessary complication that makes the code harder to understand, especially for newcomers.#yagni</p><p>And when I read it, I instantly <strong>recalled one of my discussions</strong> with colleagues about the same subject. I used to work in projects where <strong>every</strong> newly created <strong>class</strong>, <strong>had</strong> it companion, which was an <strong>interface</strong>. Those days I wasn’t thinking <strong>whether</strong> the existence of <strong>those interfaces made sense, or not</strong>. I was “<strong>programmed</strong>” to <strong>create</strong> a new <strong>interface for every</strong> new <strong>class</strong>.</p><h3>Aha moment</h3><p>Then, some day, I had an Aha<em> moment</em>. It happened when I was writing my university project.<strong> I noticed</strong> there are <strong>many interfaces</strong> and classes mapped 1:1. I wasn’t expecting to create another implementation of a given class, and even some day I need to… PHPStorm refactoring tools would help me to do it with easily. Also, it was an <strong>end-project</strong>, <strong>nobody was going to reuse it</strong> in another project, so <strong>there was no need to worry about decorating</strong> by somebody else. So… <em>do we really need interfaces</em>? Of course!</p><h3>Interfaces are important!</h3><p><strong>Interfaces are essential, and it is undeniable.</strong> But how to create interfaces correctly? To form proper use-cases for the own interfaces, we’ll take a look at them from two perspectives: an end-project and a library/framework.</p><h4>End-project perspective</h4><p>I’ll keep it simple, when to create an interface in an end-project:</p><ul><li>Two or more classes lives together, have common methods, and do similar things but in slightly another way.</li><li>You want to use some design patterns, e.g. strategy.</li><li>You need a contract for a given behavior, e.g., serializing. Furthermore, you can create a Serializable interface and attach serialize and deserialize behaviors to it.</li><li>Probably, there might be more use-cases, but these are the most commons ones, and they came across my mind at first</li></ul><p>What about mocking? Nothing. If you do not implement an interface in your class, then you shouldn’t mark it as final, so you can mock it anyway.</p><h4>Library/framework</h4><p><strong>Always</strong>. Or, at least in 99%. We want to make our libraries extendable, every possible class should allow decorating it (Open-Closed principle from SOLID). The cases when creating an interface <strong>might not</strong> be useful:</p><ul><li>Strongly framework-related classes like Symfony’s Dependency Injection configuration classes, Compiler Passes, Commands, etc.</li><li>@internal classes, but even in this case if it isn’t a big deal, I’ll provide an interface</li><li>…and I guess there are a lot more project-specific cases, but still, these are the first what came across my mind 🤷‍♂️</li></ul><p>And that’s all. Let’s use interface wisely, to not causing blurring in our code ✌️.</p><p>Thanks for reading, and see you in the next articles soon. As always, I am reminding that you can find me here:</p><p>Twitter 👉🏼 <a href="https://twitter.com/jakub_tobiasz">https://twitter.com/jakub_tobiasz</a></p><p>Mastodon 👉🏼 <a href="https://phpc.social/web/@jakubtobiasz">https://phpc.social/web/@jakubtobiasz</a></p><p>GitHub 👉🏼 <a href="https://github.com/jakubtobiasz">https://github.com/jakubtobiasz</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25c9b5c4b65d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/stop-overusing-interfaces-in-php-25c9b5c4b65d">Stop overcreating interfaces in PHP</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discover Symfony UX components and enhance your front-end]]></title>
            <link>https://medium.com/alphpaca/discover-symfony-ux-components-and-enhance-your-front-end-ffff3a7c0177?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/ffff3a7c0177</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Mon, 28 Nov 2022 18:36:46 GMT</pubDate>
            <atom:updated>2022-11-28T18:36:46.607Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lh873ndCF8SeMlm1" /><figcaption>Photo by <a href="https://unsplash.com/@afgprogrammer?utm_source=medium&amp;utm_medium=referral">Mohammad Rahmani</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><a href="https://blog.alphpaca.io/how-symfony-ux-united-two-worlds-21a89fc04410">In one of my previous stories</a>, I bring the Symfony UX concept closer. Now, when we know what and why, we are going to meet a <em>Youngster</em> — aspiring Symfony Developer wanting to impress his boss.</p><p>The Boss spent two days on reading yetanotherblogforbosses.com to find out his company’s website is missing some ✨ crucial ✨ features. The features he cannot imagine his business without.</p><p>This ✨ crucial ✨ features are:</p><ul><li><strong>A chart</strong>. But not a boring chart. The chart showing how cool we are from the time perspective.</li><li><strong>Welcome text</strong>. But not a simple welcome text. This text should be BIG. And <strong>animated</strong>! <strong>Letter by letter</strong>! You might wonder WHY DO WE NEED ANIMATED WELCOME TEXT? The boss read on the yetanotherblogforbosses.com they are cool.</li><li>Furthermore, our refreshed website should consist of <strong>input</strong>. Aaaand <strong>when you type something in this input, you should get instantly this text displayed below… reversed</strong>. And because on the yetanotherblogforbosses.com blog we can read Vue.js is cool, we need to <strong>write</strong> it <strong>in Vue</strong>.</li></ul><p>As all of these features are ✨ crucial ✨ we have to assign this task to someone special — our intern <em>Youngster</em>.</p><h3>Project setup</h3><p>To start developing our ✨ crucial ✨ features, the Youngster needs to set up a project. He needs PHP 8+, latest Node.js with npm, composer, git client, your favourite terminal, and I recommend installing <a href="https://symfony.com/download">symfony-cli</a>. Youngster’s boss read an article that databases uses a lot of energy, and as they are 🌿 eco 🌿, so they do not need them. So, when the local environment is set up, the Youngster clones the repository and runs the project:</p><pre>git clone https://github.com/alphpacademy/symfony-ux-intro<br>cd symfony-ux-intro<br>git checkout 00-start<br>composer install<br>symfony serve -d</pre><h3>Symfony Encore Bundle installation</h3><p>Encore is a glue between Symfony and JavaScript. It adds some services, config files, few boilerplate codes, and package.json. To install Encore, the Youngster has to run:</p><pre>composer require ux</pre><p>Flex will configure all files he needs to start. As new files appeared, he needs to build the frontend:</p><pre>npm install<br>npm run build</pre><blockquote>If you run into any troubles during solving the Youngster’s task on your own, he was tagging every step to be able to back in case he does something wrong 🤔. I will add a note how to skip to the given step attaching a snippet like below.</blockquote><pre>git checkout 01-cool-chart<br>composer update<br>npm install<br>npm run build</pre><h3>Being cool chart</h3><p>Time to implement the first of our new features. The Youngster knows every component from Symfony UX is described on <a href="https://ux.symfony.com./">https://ux.symfony.com.</a></p><pre>composer require symfony/ux-chartjs<br>npm install<br>npm run build</pre><p>OK, the Youngster is ready to start real coding. This “subtask” is simple — he has to pass some data from a controller to the view and render the chart. Sound like a lot of work, but is it? In src/Controller/HomepageController.php file there is a simple index method, which renders the homepage/index.html.twig view.</p><pre>#[Route(&#39;/&#39;, name: &#39;homepage&#39;)]<br>public function index(): Response<br>{<br>    return $this-&gt;render(&#39;homepage/index.html.twig&#39;);<br>}</pre><p>The first step the Youngster takes is to inject ChartBuilderInterface service, and create a line chart.</p><pre>#[Route(&#39;/&#39;, name: &#39;homepage&#39;)]<br>-public function index(): Response<br>+public function index(ChartBuilderInterface $chartBuilder): Response<br>{<br>+   $chart = $chartBuilder-&gt;createChart(Chart::TYPE_LINE);<br><br>    return $this-&gt;render(&#39;homepage/index.html.twig&#39;);<br>}</pre><p>Later he sets the data he gathered from the boss and passes the created chart object to the view.</p><pre>#[Route(&#39;/&#39;, name: &#39;homepage&#39;)]<br>-public function index(): Response<br>+public function index(ChartBuilderInterface $chartBuilder): Response<br>{<br>+   $chart = $chartBuilder-&gt;createChart(Chart::TYPE_LINE);<br>+   $chart-&gt;setData([<br>+       &#39;labels&#39; =&gt; [&#39;January&#39;, &#39;February&#39;, &#39;March&#39;, &#39;April&#39;, &#39;May&#39;, &#39;June&#39;, &#39;July&#39;],<br>+       &#39;datasets&#39; =&gt; [<br>+           [&#39;label&#39; =&gt; &#39;Cool level (in %)&#39;, &#39;data&#39; =&gt; [100, 200, 250, 350, 500, 600, 1000]]<br>+       ]<br>+   ]);<br><br>-   return $this-&gt;render(&#39;homepage/index.html.twig&#39;);<br>+   return $this-&gt;render(&#39;homepage/index.html.twig&#39;, [<br>+       &#39;chart&#39; =&gt; $chart,<br>+   ]);<br>}</pre><p>Now it is time to update the view. When the Youngster checked the file, he saw the following content:</p><pre>{% extends &#39;base.html.twig&#39; %}<br><br>{% block content %}<br>    &lt;h1&gt;Hello 👋🏼!&lt;/h1&gt;<br>{% endblock %}</pre><p>Now, after reading <a href="https://ux.symfony.com/chartjs">the component’s short documentation</a>, and after applying advanced frontend magic 🧙, the Youngster achieved the following result:</p><pre>{% extends &#39;base.html.twig&#39; %}<br><br>{% block content %}<br>    &lt;h1&gt;Hello 👋🏼!&lt;/h1&gt;<br>+<br>+   &lt;hr /&gt;<br>+<br>+   &lt;div class=&quot;container&quot;&gt;<br>+       &lt;h2&gt;How cool are we?&lt;/h2&gt;<br>+       {{ render_chart(chart)}}<br>+  &lt;/div&gt;<br>{% endblock %}</pre><p>At the end of the day #1 the company’s website looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kK-L7kWCYDrp1v5EFNjeHQ@2x.png" /></figure><p>Really cool, huh.</p><blockquote>If you run into any troubles during solving the Youngster’s task on your own, he was tagging every step to be able to back in case he does something wrong 🤔.</blockquote><pre>git checkout 02-welcome-text<br>composer update<br>npm install<br>npm run build</pre><h3>Welcome text</h3><p>Now it is time to implement welcome text, typed letter by letter. Thanks to <a href="https://ux.symfony.com/typed">Typed component page</a>, Youngster knows he must run the following commands:</p><pre>composer require symfony/ux-typed<br>npm install<br>npm run build</pre><p>Now, as welcome text already exist, the only task is to animate it. After opening homepage/index.html.twig and with using <a href="https://symfony.com/bundles/ux-typed/current/index.html">Symfony UX Typed documentation</a>, the Youngster made the following changes:</p><pre>{% extends &#39;base.html.twig&#39; %}<br><br>{% block content %}<br>-   &lt;h1&gt;Hello 👋🏼!&lt;/h1&gt;<br>+   &lt;h1 {{ stimulus_controller(&#39;symfony/ux-typed&#39;, {<br>+          strings: [&#39;Hello 👋!&#39;],<br>+          showCursor: false,<br>+          cursorChar: &#39;✨&#39;,<br>+          smartBackspace: true,<br>+      })}}&gt;&lt;/h1&gt;<br><br>    &lt;hr /&gt;<br><br>    &lt;div class=&quot;container&quot;&gt;<br>        &lt;h2&gt;How cool are we?&lt;/h2&gt;<br>        {{ render_chart(chart)}}<br>    &lt;/div&gt;<br>{% endblock %}</pre><p>And here we go, after three command and six new lines of code, new ✨ shiny ✨ welcome text is ready!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*I0NR7bECnKaErhSCyrAadg.gif" /><figcaption>Animated welcome text created with using Symfony UX Typed</figcaption></figure><blockquote>If you run into any troubles during solving the Youngster’s task on your own, he was tagging every step to be able to back in case he does something wrong 🤔.</blockquote><pre>git checkout 03-input-vue<br>composer update<br>npm install<br>npm run build</pre><h3>Final boss — Magic reversing input in Vue</h3><p>After the previous experience and 3 courses about Vue.js on YouAintWatchAnyBoughtVideoDemy, the Youngster is ready to implement the last ✨ crucial ✨ feature.</p><p>Documentation? <a href="https://symfony.com/bundles/ux-vue/current/index.html">Symfony UX Vue.js Documentation</a>. ✅</p><p>Commands? ✅</p><pre>composer require symfony/ux-vue<br>npm install<br>npm install vue-loader --save-dev</pre><p>Following the documentation, the Youngster started with configuring Encore. He needs to edit two files: webpack.config.js and assets/app.js (SPOILER ALERT! He needs to create a assets/vue/components directory, too).</p><p>In the webpack.config.js he has to enable Vue.js loaderby adding the following line:</p><pre>const Encore = require(&#39;@symfony/webpack-encore&#39;);<br><br>// Manually configure the runtime environment if not already configured yet by the &quot;encore&quot; command.<br>// It&#39;s useful when you use tools that rely on webpack.config.js file.<br>if (!Encore.isRuntimeEnvironmentConfigured()) {<br>    Encore.configureRuntimeEnvironment(process.env.NODE_ENV || &#39;dev&#39;);<br>}<br><br>Encore<br>    // directory where compiled assets will be stored<br>    .setOutputPath(&#39;public/build/&#39;)<br>    <br>    // a lot of content here<br><br>    // uncomment if you&#39;re having problems with a jQuery plugin<br>    //.autoProvidejQuery()<br>+   .enableVueLoader()<br>;<br><br>module.exports = Encore.getWebpackConfig();</pre><p>In the assets/app.js the Youngster is going to register Vue components:</p><pre>/*<br> * Welcome to your app&#39;s main JavaScript file!<br> *<br> * We recommend including the built version of this JavaScript file<br> * (and its CSS file) in your base layout (base.html.twig).<br> */<br>+<br>+import { registerVueControllerComponents } from &#39;@symfony/ux-vue&#39;;<br><br>// any CSS you import will output into a single css file (app.css in this case)<br>import &#39;./styles/app.css&#39;;<br><br>// start the Stimulus application<br>import &#39;./bootstrap&#39;;<br><br>+registerVueControllerComponents(require.context(&#39;./vue/components&#39;, true, /\.vue$/));</pre><p>Now, it is a time to use the Vue knowledge from video courses (to be honest, he copied this code from StackOverflow, but do not tell his boss 🤫)😎.</p><p>He created assets/vue/components/ReversingInput.vue file and p̵a̵s̵t̵e̵ write the highly complexed code:</p><pre>&lt;template&gt;<br>  &lt;input v-model=&quot;message&quot; /&gt;<br>  &lt;p&gt;Reversed value is: {{ message.split(&#39;&#39;).reverse().join(&#39;&#39;) }}&lt;/p&gt;<br>&lt;/template&gt;<br><br>&lt;script&gt;<br>export default {<br>  name: &quot;ReversingInput&quot;,<br>  data() {<br>    return {<br>      message: &quot;&quot;,<br>    }<br>  },<br>}<br>&lt;/script&gt;</pre><p>The last step is to render the new component on the homepage. To accomplish this step, the Youngster opened the templates/homepage/index.html.twig file and added the following lines:</p><pre>{% extends &#39;base.html.twig&#39; %}<br><br>{% block content %}<br>    &lt;h1 {{ stimulus_controller(&#39;symfony/ux-typed&#39;, {<br>            strings: [&#39;Hello 👋!&#39;],<br>            showCursor: false,<br>            cursorChar: &#39;✨&#39;,<br>            smartBackspace: true,<br>        })}}&gt;&lt;/h1&gt;<br><br>    &lt;hr /&gt;<br><br>    &lt;div class=&quot;container&quot;&gt;<br>        &lt;h2&gt;How cool are we?&lt;/h2&gt;<br>        {{ render_chart(chart)}}<br>+<br>+       &lt;h2&gt;Reversing input - Really cool!&lt;/h2&gt;<br>+       &lt;div {{ vue_component(&#39;ReversingInput&#39;) }}&gt;&lt;/div&gt;<br>    &lt;/div&gt;<br>{% endblock %}</pre><p>And the result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*RYrQyB4rI207rxtK-xr74w.gif" /></figure><p>The boss must be proud of the Youngster’s job 😎. This new website is way cooler than before!</p><p>I wrote this article in a little different way, I hope it is readable. I was unable to cover all topics, and I focused on the more practise side of using Symfony UX. If you feel this article is too basic for you, I plan to write another one, more advanced, and embedded in Sylius.</p><p>Thanks for reading, and see you in the next articles soon. As always, I am reminding that you can find me here:</p><ul><li>Twitter 👉🏼 <a href="https://twitter.com/jakub_tobiasz">https://twitter.com/jakub_tobiasz</a></li><li>Mastodon 👉🏼 <a href="https://phpc.social/web/@jakubtobiasz">https://phpc.social/web/@jakubtobiasz</a></li><li>GitHub 👉🏼 <a href="https://github.com/jakubtobiasz">https://github.com/jakubtobiasz</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ffff3a7c0177" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/discover-symfony-ux-components-and-enhance-your-front-end-ffff3a7c0177">Discover Symfony UX components and enhance your front-end</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interview With Mateusz Zalewski — BDD Magician From Sylius]]></title>
            <link>https://medium.com/alphpaca/interview-with-mateusz-zalewski-bdd-magician-from-sylius-e78583b7e34?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/e78583b7e34</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[bdd-testing]]></category>
            <category><![CDATA[testing-framework]]></category>
            <category><![CDATA[bdd]]></category>
            <category><![CDATA[testing-tools]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Tue, 15 Nov 2022 16:19:27 GMT</pubDate>
            <atom:updated>2022-11-15T16:19:27.993Z</atom:updated>
            <content:encoded><![CDATA[<h3>Interview With Mateusz Zalewski — BDD Magician From Sylius</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j4Xr5DbdRn7RGYIc" /><figcaption>Photo by <a href="https://unsplash.com/@kaleidico?utm_source=medium&amp;utm_medium=referral">Kaleidico</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Today, my guest is Mateusz Zalewski. We are working together in Sylius, a Polish e-commerce framework where Behavior-Driven Development is a crucial element of software development. There are two widely used tools in the PHP ecosystem when we talk about BDD: Behat and PHPSpec. This interview will give you overall knowledge about BDD, but we will also cover some concepts in detail. Enjoy!</p><p>In this interview, we will talk about:</p><ul><li>What is Behavior-Driven Development</li><li>How to start with BDD</li><li>What is the difference between a specification and a classic unit test</li></ul><p><strong>So, Mateusz, you promote BDD a lot. Tell us about your experience with Behavior-Driven Development. How long do you follow BDD, and why do you like it so much?</strong></p><blockquote>First of all, thank you for the invitation, Kuba. I’m very glad I can share my experience, especially in the topic so close to my heart and everyday work!</blockquote><blockquote>Before I started to work with Sylius I had no idea about test-driven methodologies. I started using Test-Driven- and Behavior-Driven Development around 8 years ago… and it <strong>wasn’t</strong> a love at first sight :D It took me a while to understand the true power of BDD — it’s ability to lead the software development process into the business goal, feeling of security it gives to the whole team, and flexibility it introduces into the everyday work. But since I realize it — I cannot imagine creating an app without this approach.</blockquote><p><strong>Let’s say I am totally newbie in BDD and I ask you to advise me how to start with BDD. Do you have any suggestions for such person?</strong></p><blockquote>Firstly — give yourself a time. Even though the basics or BDD are quite understandable, it’s a long process to fully understand “what, on earth, is going on” and distinguish it from the standard BDD. Try to focus on answering a question “why I need this feature?” and “who would take a benfit from it?”. It’s a good starting point to start seeing what BDD is mainly about — expressing the business value in the application.</blockquote><p><strong>When we talk about BDD tools, we can categorize them as those using specification as an input (in the PHP it is PHPSpec) and those using user stories (like Behat). I would like to focus on those first. Can you tell us how do you see a difference between specs and classic unit tests?</strong></p><blockquote><em>Technically,</em> the difference is negligible. In the end, you always have a unit test for the class. The main difference is in the approach, or rather the developer’s intention. You do not try to test the functionality of the class, but describe its behavior (or how you want it to be). This semantic difference is usually depreciated by developers, but it makes a huge change in the attitude and therefore influences the execution. Of course, there are also less philosophical differences — mocking is much easier in PHPSpec, as well as its syntax seems a little bit more natural… which can be a pro but also a con, depending on the developer :)</blockquote><p><strong>Ok, but do we need PHPSpec? Sometimes I feel there is no significant difference between PHPSpec and PHPUnit, and we can achieve the same with both. What is your opinion? Is it just the way how we write the tests, or something more?</strong></p><blockquote>Definitely BDD is not about using the specific tool. Even though PHPSpec and Behat were specifically created for BDD, using them is not required to introduce this approach into your development process. And on the other way — just because you use them does not necessarily mean you use BDD.</blockquote><blockquote>If using PHPUnit is more natural for you — not a problem. Such methodologies are created to make your life easier not harder. Writing a proper, business-value oriented description of the class in PHPUnit is far more valuable than writing a poor specification with PHPSpec.</blockquote><p><strong>Coming back to you and your relationship with BDD — image you are looking for a new job, is BDD a must-have, or you are BFF with it, and you cannot imagine working without it?</strong></p><blockquote>Both :D Definitely a solid TDD and BDD practice would be a huge advantage for me if I were looking for a new job. But I understand introducing them is not a default practice. Definitely if I join a company without such approach, I would spend a lot of time trying to introduce it for the Team and convince everyone about its benefits.</blockquote><p><strong>And the last questions — is BDD suitable for every size project? Writing scenarios, then implementing contexts seem to be a lot of work. Maybe it is an overkill for one-man army projects and in small projects it is better to stick the “traditional” way?</strong></p><blockquote>I think it’s not about the size, but about what the project is about. From my experience, for any project that has a complex domain and business requirements that need to be reflected in the application, BDD is usually a winning approach. But indeed, for very simple and small e.g. CRUD-only projects, it can be overkill. On the other hand — such “small projects just for 2 months” tend to transform into long-time complicated applications. And BDD shows its real value, especially in a long term. The BDD approach does not have to be introduced fully. You can start using feature scenarios for the communication between business and technical people, skipping the tests automatization part — and see what happens next. Worst-case scenario — you have a well-documented application :).</blockquote><p><strong>Thank you very much for your time! I hope this interview will be a next small contribution in helping you to promote BDD in our community of developers.</strong></p><blockquote>Thank you as well! It was a huge pleasure, I hope I made someone interested in the topic. Can I allow myself a little personal advertisement? :) For everyone eager to introduce BDD in their development practice, at the beginning of the next year I plan to start a “BDD Master” online course, in which I will present both theory and practice of Behavior-Driven Development and how to introduce it into your application. Sign up, to receive updates about it. I hope I will be able to share the BDD world even further 🎉</blockquote><p>If you have any questions to Mateusz, you can find him here:</p><p>👉🏼 Twitter: <a href="https://twitter.com/mpzalewski">@mpzalewski</a><br>👉🏼 GitHub: <a href="https://github.com/Zales0123">Zales0123</a><br>👉🏼 BDD-Master Course: <a href="https://bdd-master.com/">https://bdd-master.com/</a></p><p>What about you, dear reader? Have you ever touched BDD-related topics? What do you think about them? Share your experience with us in the comment section 👇🏼.</p><p>Moreover, if you want to be always up-to-date with my content, you can follow me on <a href="https://twitter.com/jakub_tobiasz">Twitter</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e78583b7e34" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/interview-with-mateusz-zalewski-bdd-magician-from-sylius-e78583b7e34">Interview With Mateusz Zalewski — BDD Magician From Sylius</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Symfony UX United Two Worlds]]></title>
            <link>https://medium.com/alphpaca/how-symfony-ux-united-two-worlds-21a89fc04410?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/21a89fc04410</guid>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 20:10:57 GMT</pubDate>
            <atom:updated>2022-11-13T20:18:37.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h1g7X3ixUx07Ry0Q" /><figcaption>Photo by <a href="https://unsplash.com/@medbadrc?utm_source=medium&amp;utm_medium=referral">Med Badr Chemmaoui</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>For many years Symfony applications had poor front-end side, with assets put directly into the public directory, without any modern toolset. Now, we have a Symfony UX. But what exactly is Symfony UX? How it revolutionized Symfony apps? Let’s take this journey together!</p><h3>The beginning</h3><p>In 2017 Symfony UX started forming, but it was not named Symfony UX those days. <strong>In 2017 Symfony created</strong> a core element of Symfony UX, which is S<strong>ymfony Webpack Encore consisted of</strong> two packages: <strong>symfony/webpack-encore-bundle</strong> (back-end part) <strong>and @symfony/webpack-encore</strong> (front-end part). The goal of these two packages is to make integrating with Webpack easier. It does not do much, as <strong>it</strong> only <strong>provides better configuration experience</strong> and <strong>loads the right files in the Symfony application</strong>, but it is enough.</p><h3>Borrowing is cool</h3><p><strong>Along the Encore</strong>, in the era of SPA, <strong>Symfony has chosen</strong> something different than typical <strong>front-end framework</strong> or library like Angular, Vue or React. What did Symfony pick? <strong>Stimulus</strong>. What is Stimulus? It is a <strong>JS framework with a pretty stable position in Ruby on Rails community</strong>. It does not offer the experience you might know from other frameworks, but it is better than nothing, and also is a <strong>pretty good entry point for moving away from Twig-based projects</strong>. You can read more about Stimulus by going to <a href="https://stimulus.hotwired.dev/">its official site</a>.</p><h3>Christmas gift</h3><p>In December 2020, <strong>Symfony announced Symfony UX</strong>. But still, what is Symfony UX. Is it a new framework? Maybe new library? Nope. Symfony UX is a “code name” for <strong>a set of libraries solving the most common cases like drop zones, charts or lazy loading images</strong>. But how Chart.js from Symfony UX is different from the classic Chart.js? Under the hood it is the same Chart.js library. The only <strong>difference is how we install it, configure, and use it</strong>. <strong>Every of these steps is simplified</strong> and adjusted to Symfony’s “way of doing things”.</p><h3>Finishing touches</h3><p>18 months after our Christmas gift, <a href="https://ux.symfony.com/"><strong>ux.symfony.com</strong></a><strong> has been announced</strong>, along with <strong>four new components</strong>. What is more important, <strong>one of these components was a component allowing to render React components</strong>. <strong>Another interesting</strong> one was <strong>Live Component, allowing to build independent Twig components wired with their own service class</strong>. What is it such exciting for me? <strong>No more passing data down</strong> to the right component, we can inject a repository to the service class and gather the data we need.</p><h3>Booooring, show me the code 👨‍💻</h3><p>This journey despite having no code example is a crucial part of a bigger adventure. I wanted to make sure you know what Symfony UX is, before we dive into more technical aspects. In the following days I am going to create two additional articles, one about Symfony UX in Symfony apps, and another one for Symfony UX embedded in Sylius. Despite Sylius technically is a Symfony, we need to make few additional steps to improve our front-end stack in Sylius 💃.</p><p>So, what I want you to remember:</p><ul><li>Symfony UX is not a thing itself, it is a set of packages integrating some JS libraries with Symfony</li><li>Thanks to Symfony UX packages, we are able to render React, Vue and Twig components easier</li><li>Symfony UX can be a great step in transition from Twig-based project to a SPA one</li></ul><p>Thanks for reading, and see you in a more code-rich articles soon. As always, I am reminding that you can find me here:</p><ul><li>Twitter 👉🏼 <a href="https://twitter.com/jakub_tobiasz">https://twitter.com/jakub_tobiasz</a></li><li>Mastodon 👉🏼 <a href="https://phpc.social/web/@jakubtobiasz">https://phpc.social/web/@jakubtobiasz</a></li><li>GitHub 👉🏼 <a href="https://github.com/jakubtobiasz">https://github.com/jakubtobiasz</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21a89fc04410" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/how-symfony-ux-united-two-worlds-21a89fc04410">How Symfony UX United Two Worlds</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Secure your franken elePHPant — the story how I made SSL working with FrankenPHP in Docker]]></title>
            <link>https://medium.com/alphpaca/secure-your-franken-elephpant-the-story-how-i-made-ssl-working-with-frankenphp-in-docker-34ce0d33cacf?source=rss-f746aad858ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/34ce0d33cacf</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[development-tools]]></category>
            <category><![CDATA[frankenphp]]></category>
            <dc:creator><![CDATA[Jacob Tobiasz]]></dc:creator>
            <pubDate>Tue, 01 Nov 2022 14:19:26 GMT</pubDate>
            <atom:updated>2022-11-01T18:41:00.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Secure your franken elePHPant — the story how I made SSL working with FrankenPHP in Docker</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VKM39NQ2liL9NpYm" /><figcaption>Photo by <a href="https://unsplash.com/@kaffeebart?utm_source=medium&amp;utm_medium=referral">Kaffeebart</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>My current development stack is pretty standard — I have a container with Nginx, PHP-FPM, MariaDB, and a few other services depending on the project. Also, to make my stack a little cooler (😎), I have Dnsmasq catching all *.pond domains and pointing them to 127.0.0.1. The icing on the cake is a container with Traefik what is listening on ports :80 and :443 and forwards the traffic to the right container depending on the domain.</p><p>I have decided to clean my development environment (some things need refactoring) and switch to FrankenPHP on the project’s container level. I decided to do it in two steps. The first is to make it work in “isolation” (without the Traefik and other magic things), and the second is to embed it in my current workflow.</p><p>In this story, we will focus on how to make SSL work with FrankenPHP inside a container.</p><p><strong>TLDR;</strong> I am moving from NGINX + PHP-FPM to FrankenPHP for my development stack 🤷🏼‍♂️</p><h3>Does not Caddy support SSL locally out-of-the-box?</h3><p>It is! But not inside a container. Additionally, even though we have figured out how to use Caddy’s SSL, every instance has its certificate and key. So… we are going to</p><ul><li>Set up a fresh Symfony application</li><li>Generate our certificate using mkcert (for now, we will focus on a working localhost domain)</li><li>Pass our certificate and key to the container</li><li>Make FrankenPHP using our certificate</li></ul><h3>Setting up a fresh Symfony application</h3><p>To keep things simple and separate, we will have our Symfony application in its folder inside our “project” directory. I have used the following commands:</p><pre>mkdir FrankenSymfony<br>cd Franken Symfony<br>symfony new --version lts --dir app</pre><p>I have ended with the project directory FrankenSymfony with a single app directory holding the Symfony app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/375/1*7EDs_nlQhCpFgUHC5UcJ2A@2x.png" /><figcaption>Initial project structure</figcaption></figure><p>In the newest Symfony versions symfony/runtime component is already installed so the only thing we need to do is setting the proper runtime in our composer.json .</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/30fbe3cbe8591ede5b0fe16f47551966/href">https://medium.com/media/30fbe3cbe8591ede5b0fe16f47551966/href</a></iframe><h3>Generating our certificate</h3><p>To achieve this goal we need a tool named mkcert . The easiest way to install it is to use <a href="https://brew.sh/">Homebrew</a> (you can install it also on <a href="https://docs.brew.sh/Homebrew-on-Linux">Linux</a>).</p><pre>brew install mkcert</pre><p>When we have mkcert installed, make sure you are in your project’s root and run following commands:</p><pre>mkcert -install<br>mkcert &#39;localhost&#39;</pre><p>The first command adds the local CA to the system trust store, and the second command generates a certificate for our localhost domain.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/374/1*7cQwAKEnYYPUyRstr97vEw@2x.png" /><figcaption>Certificate and key files inside our project</figcaption></figure><p>I have decided to put generated certificates in certs sub-directory, but you can left them in the project’s root directory.</p><h3>Setting up a docker-compose.yaml file</h3><p>For now, we will just create docker-compose.yaml file and use the default FrankenPHP Docker image. In the feature we might need to create custom Dockerfile as many of PHP extensions are not installed by default, but let’s keep things simple.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78f625bf3d21a00b031581ccd125667a/href">https://medium.com/media/78f625bf3d21a00b031581ccd125667a/href</a></iframe><h3>Telling FrankenPHP to use our certificate</h3><p>Now we must tell Franken to use localhost.pem. We need to create Caddyfile with the following content:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/052551721f432912a2e335919355b985/href">https://medium.com/media/052551721f432912a2e335919355b985/href</a></iframe><p>Now using tls directive between {$SEVER_NAME:localhost} and log I add</p><pre>tls /etc/app/certs/localhost.pem /etc/app/certs/localhost-key.pem</pre><p>The final Caddyfile should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/362a8feb883deeb6eeb75253c25a90f3/href">https://medium.com/media/362a8feb883deeb6eeb75253c25a90f3/href</a></iframe><p>The last step is to pass our Caddyfile to the container and voila. With the following docker-compose.yaml (psst, notice we have added mapping on line 12):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54df869fb5fc9590d21e4bf9e9fa1b7c/href">https://medium.com/media/54df869fb5fc9590d21e4bf9e9fa1b7c/href</a></iframe><p>we can run docker compose up -d, go to our browser, type https://localhost and BANG. We have fully working SSL certificate 😎!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MVaT8h_sMdHptJmNtQ9CnA@2x.png" /><figcaption>Certificate details, no warning, no error displayed near SSL icon</figcaption></figure><p>By modifying Caddyfile and playing with hosts file we can use our custom domain 😎.</p><p>Thanks for reading! If you want, you can to find me on:</p><ul><li>Twitter 👉🏼 <a href="https://twitter.com/jakub_tobiasz">https://twitter.com/jakub_tobiasz</a></li><li>Mastodon 👉🏼 <a href="https://phpc.social/web/@jakubtobiasz">https://phpc.social/web/@jakubtobiasz</a></li><li>GitHub 👉🏼 <a href="https://github.com/jakubtobiasz">https://github.com/jakubtobiasz</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34ce0d33cacf" width="1" height="1" alt=""><hr><p><a href="https://medium.com/alphpaca/secure-your-franken-elephpant-the-story-how-i-made-ssl-working-with-frankenphp-in-docker-34ce0d33cacf">Secure your franken elePHPant — the story how I made SSL working with FrankenPHP in Docker</a> was originally published in <a href="https://medium.com/alphpaca">Alphpaca</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>