<?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 Oliver de Cramer on Medium]]></title>
        <description><![CDATA[Stories by Oliver de Cramer on Medium]]></description>
        <link>https://medium.com/@oliverde8?source=rss-8d7360674de4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GihsyN69w0L8IW1zi6hJ4Q.jpeg</url>
            <title>Stories by Oliver de Cramer on Medium</title>
            <link>https://medium.com/@oliverde8?source=rss-8d7360674de4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:36:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oliverde8/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[A Little Sylius Adventure]]></title>
            <link>https://oliverde8.medium.com/a-little-sylius-adventure-f9e9c96f6b23?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f9e9c96f6b23</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[symfony]]></category>
            <category><![CDATA[sylius]]></category>
            <category><![CDATA[magento]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Sat, 15 Jan 2022 09:06:28 GMT</pubDate>
            <atom:updated>2022-01-15T09:08:41.656Z</atom:updated>
            <content:encoded><![CDATA[<h4>From the perspective of a Magento developer.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WWQcLlwMVN6KTu33.jpg" /></figure><p>For over 7 years I have mostly worked on e-commerce projects. Most of them were <strong>Magento</strong> 1 &amp; 2 projects with a few adventures with other solutions (Drupal commerce 😱). I never truly enjoyed developing on any of the e-commerce projects. There were some challenges that were fun, but most of the time the challenge has been to make the framework/cms do something it was not meant to do, it was most often about workarounds and not creating a new nice maintainable code.</p><p>So when beginning of this summer I was given the opportunity to work on a <a href="https://sylius.com/"><strong>Sylius</strong> </a>project that didn’t sell products, but subscriptions I jumped on the occasion. I wanted to work on a Sylius project for a while now and this project was different from any I had worked on before. I knew that with the budget &amp; time we had it would have been impossible to do the project using Magento. Therefore it would be interesting to really see how flexible Sylius can be.</p><p>Now that the website has been running for a while I can say, yes Sylius is flexible. And it mostly comes down to how simple everything is.</p><h4>Symfony under the hood</h4><p>Sylius uses Symfony, so we get all the flexibility the Symfony framework offers.</p><p>Wish to create a new entity? <em>make:entity</em> and let the command line guide you.</p><p>Wish to make permissions and complex rules, <em>make:voter</em> and again let yourself be guided. Even changing the behaviour of the permissions in the Back office it’s just a breeze. And that is even though permissions are a “Plus Edition” feature and we are using the open-source version. Our permissions are actually quite different than what the Plus version offers, we have permission on actions, but also on individual data. Some admins for example can see only some orders. All this is made possible with little code because of how simple the underlying system is.</p><p>Want to change the checkout? Well, it’s twig templates and Symfony forms. Modifying the steps will require an additional 30 minutes of reading documentation about <a href="https://docs.sylius.com/en/1.9/book/architecture/state_machine.html">State Machines</a>, but that’s it. Things were built to be changed.</p><p>Running Symfony with doctrine make most of the most repetitive task extremely easy and fast. On top of that, the Symfony debug toolbar is constantly there, showing you how many queries are running on a page, which voter was used and any other debug information you might need.</p><p>Having Symfony also means we have access to all the Symfony bundles out there. Need 2FA authentification? There is a bundle for that. You can install and make it work with Sylius with ease as long as you understand bundles are not like WordPress plugins; they require the developer to plug the things together in yaml files.</p><h4>Sylius is good</h4><p>When you are out of the Symfony world look more into doing things in sylius, it remains mostly simple.</p><p>Need to store your files on a bucket on not on local file storage? You just need to configure the file abstraction layer. So no need for old school NFS mounts on the server that might fail and start creating strange behaviours. Sylius can connect to pretty much any storage solution.</p><p>Need to use an asynchronous queue? With Magento, you are obliged to use RabbitMq; which is not straightforward to have with Azure or Aws. Sylius? you can use your MySQL database if your queue is small or you can use the proprietary solution of both hosting solutions. That’s again thanks to the proper abstraction layer, which means it’s only some configuration to use pretty much any solution.</p><p>Sylius is also fast; without any page cache or query cache, our website is running without a sweat with an average response time of 150ms. And we still have a few quick-win optimisations. With Magento, it’s impossible to achieve this kind of load time without the page cache. Page caching is an important tool in a developers arsenal, but it must not be there to hide underlying issues as it does with Magento.</p><h4>The bad</h4><p>As with all solutions, Sylius is not perfect.</p><p>Most native entities &amp; also the backend controllers use a <em>ResourceController</em>. In my opinion, this controller has way too much logic in it. So if you need to change a certain behaviour so very slightly you end up rewriting entire functions. Even adding additional parameters to the twig rendering is not always possible.</p><p>I don’t like much creating new views in the admin, it requires a lot of repetitive yml declaration. I think most of it could have been simplified.</p><p>Some of the critics of Sylius are the lack of features out of the box. But I think that is actually a good thing. It’s part of why it’s so easy to customize. There are community modules that allow adding some of those features.</p><p>One feature I would have really liked to see is a configuration module. Most contributions in Sylius is done on individual entities. Need to have a new way for users to pay? well, you will create a new Payment and select the provider you wish and configure it for each country. This makes sense. It also adds flexibility.</p><p>This also has its limitation, we needed to have for each country a few dozen texts to be configurable; add DataLayer ids and other configurations. All these would need to be stored on the “channel” entity. The page to edit the entity becomes quite messy very quickly. Some of these configurations you might argue could be a parameter in a yaml file, but in most cases, we are not masters of these data and they change more than they should.</p><p>This is why the used my <a href="https://github.com/oliverde8/comfyBundle"><strong>ComfyBundle </strong></a>which allows us to have configurations per channel &amp; language. We should soon make public the bundle that allowed us to integrate this bundle to Sylius and have a backend interface to make the configurations.</p><h4>Conclusion</h4><p>I think Sylius is a really good Commerce solution. Like everything it’s not for everybody; we can still make cheaper websites with Magento, and even cheaper ones with SASS solutions. But I believe that with the right budget a Sylius website will be a better one as it will compromise less.</p><p>Magento does offer more features but those features are harder to alter, and some of them are either bugged or <a href="https://medium.com/geekculture/magento-commerce-staging-what-it-is-and-its-dark-secret-985b393a8fc5"><em>not conceived properly</em></a>.</p><p>Personally, I enjoyed a lot my experience with Sylius. It was a challenging project with complex features &amp; a very tight timeframe. The existing code in Sylius was rarely of a hindrance, we rarely had to implement workarounds that made no sense and were untestable.</p><p>I would definitively recommend Sylius for future projects; it has a growing community and it improves at each iteration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f9e9c96f6b23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to migrate from Travis-ci.org to .com]]></title>
            <link>https://oliverde8.medium.com/how-to-migrate-from-travis-ci-org-to-com-5fbcfa541777?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5fbcfa541777</guid>
            <category><![CDATA[continuous-integration]]></category>
            <category><![CDATA[travis-ci]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Mon, 30 Aug 2021 11:39:43 GMT</pubDate>
            <atom:updated>2021-08-30T11:40:38.762Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to migrate from Travis-ci.org to .com</h3><h4>it’s not as simple as you might assume.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*3aI1UDZ_sYKomZb3eFQlYA.png" /></figure><p>For a while now <a href="https://travis-ci.org/">Travis-ci.org</a> has been showing that we would soon need to migrate to <a href="https://www.travis-ci.com/">Travis-ci.com</a> which I assumed was just a matter of URL change and that it would require no action on my part.</p><p>Today I did some changes to 2 of my public libraries, and I do test them locally but I trust Travis to run the tests on multiple PHP versions. To my surprise Travis-ci didn’t I, therefore, couldn’t be sure my changes were working on older versions of PHP.</p><p>I had to migrate to <a href="https://www.travis-ci.com/">Travis-ci.com</a>; So here is my small journey of migration that as the title suggested was more complicated than I thought it would be. Spoilers, it’s not technically complicated it’s just that the documentation is not complete.</p><p>If you are not interested in my journey you can just skip to <a href="#47c8">the second part of this article</a> on how to do a migration from <a href="https://travis-ci.org/">Travis-ci.org</a> to <a href="https://www.travis-ci.com/">Travis-ci.com</a></p><h3>My journey to migrate</h3><p>My first step was to create an account on <a href="https://www.travis-ci.com/">Travis-ci.com</a> using my github account. This was easy enough; after doing this I was asked to enable the Travis integration in GitHub. A link sent me to the right page and it was easy.</p><p>At first, all looked well, I could see a few of my projects. But then I realized that I was missing the repository I just had updated and wanted to try. Digging a bit more I found that all the repositories that I was missing all the repositories I had on <a href="https://travis-ci.org/">Travis-ci.org</a>.</p><p>I realized at this point that I probably had to do a migration. I found this <a href="https://docs.travis-ci.com/user/migrate/open-source-repository-migration">documentation</a>. I followed the documentation till the step where it asked me to migrate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/0*pHGOpILXna6KmaEw.png" /></figure><p>The thing is, I couldn&#39;t. it said I needed to sign up to the beta to perform this action. This confused me, my data had not migrated to <a href="https://www.travis-ci.com/">Travis-ci.com</a>, so why wouldn’t I be able to simply create a new project in Travis? I was ready at this point to set up my project from scratch. But I couldn’t find any way to do that either because those projects wouldn’t show up on <a href="https://www.travis-ci.com/">Travis-ci.com</a>.</p><p>I found this behaviour extremely strange. I mean if it can detect that the projects are already in <a href="https://www.travis-ci.com/">Travis-ci.com</a> why not just migrate them? And if <a href="https://travis-ci.org/">Travis-ci.org</a> has been disabled why isn’t there a procedure that’s not in beta?</p><p>I found myself in a dilemma:</p><ul><li>I can’t register my old libraries because they exist in .org</li><li>I can’t migrate them from .org without registering to the beta.</li></ul><p>Not finding any solution I ended up subscribing to the beta is easy enough. And a few minutes later I have the migrate button 🎊 🎉.</p><p>I select my projects to migrate and nothing; there are a few loading screens the migration seems to happen; but then; nothing. I can’t see a single project under my account anymore. I enter the URL of the project, and there I can see it. I see the history and everything. But it’s not visible under my repositories.</p><p>After a bit more frustration, it was a simple fix as well. I just logged out and logged in again. Good thing I am used to Magento…</p><p>Now I can see the migrated projects, so I do a commit in order to have a new build test my latest code that at this point I need to publish asap.</p><p>Nothing happens, Looking around a bit in Travis I find this error:</p><blockquote>Could not authorize build request for</blockquote><p>Looking on the internet I found that by default the “Free Plan” is not selected. Therefore Travis considers that I can’t build at all. So I needed to enable the Free plan manually.</p><p>And now we are in business, and my builds are running once more.</p><p>Travis is definitively one of the best tools out there, and the service it provides for free is great. The detection of projects in <a href="https://travis-ci.org/">Travis-ci.org</a> exists. So why not use that to display to the user the procedure directly? That would have make it more simple? There are probably technical reasons why the update is not more transparent. But a simple list of things to do would have allowed me and probably others to gain literally hours.</p><p>Hopefully, this little how-to migrate, can help a few of you with some of the frustration I had.</p><h3>How to migrate from Travis Org to Com</h3><p>1- First log in with your GitHub account <a href="https://www.travis-ci.com/">Travis-ci.com</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/609/1*PJ83Q0VNL8tdMDxtgZiH8A.png" /></figure><p>2- Authorize Travis for the repositories you would like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*pRXa67vf-ULmRbWBZYDn2Q.png" /></figure><p>3- In Travis-Ci go to the migration tab and ask to join the beta</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16UuhOlSH0IC-7RA1LHJTQ.png" /></figure><p>4- While waiting for the beta to be enabled on your account select the free plan.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/1*5NC4CaI-kmFWrvH8u8JjJw.png" /></figure><p>5- Go back to the migration tab, and wait for the migration options to appear.</p><p>6- Select the repos you would like to migrate, and click on migrate.</p><p>7- Logout</p><p>8- Login Again</p><p>9- All should be good now, if you do a commit in one of your repos it should start to build.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5fbcfa541777" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magento Commerce- Staging — What It Is and Its Dark Secret]]></title>
            <link>https://medium.com/geekculture/magento-commerce-staging-what-it-is-and-its-dark-secret-985b393a8fc5?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/985b393a8fc5</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[magento]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Fri, 12 Mar 2021 08:29:56 GMT</pubDate>
            <atom:updated>2021-08-26T15:52:35.064Z</atom:updated>
            <content:encoded><![CDATA[<h3>Magento Commerce— Staging — What It Is and Its Dark Secret</h3><h4>Magento2 Commerce has introduced a while ago a “staging” functionality. This functionality, which on paper is great has a dark secret.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/925/1*jdPJCEgdquAcbAad60_n_Q.jpeg" /></figure><p>First of all, let us see what is this staging functionality?</p><p>You might need a certain page, such as a CMS page, or a product, or even a category page to change at a very specific time &amp; date. For example, you are selling a product for Christmas, and you would like to stop selling it on the 24th at midnight.</p><p>The staging functionality allows you to configure in the back office multiple states for a product, a category, or a CMS page. We can for example, create a stage for our product in order for it to be enabled on the 23rd of December and disabled on the 24th at midnight. This means customers visiting the website on the 22nd at 23h59m will not be able to find the product. But if they visit the website on the 23rd at 00h01m they will (nearly).</p><p>You can use this to change any product attribute; you can also use it to change a category page to add temporarily a banner for example on the page, or to publish the category at a given time.</p><p>Without this, you would need to have an admin do the changes at a given time, and even then he might be late doing some of the changes; make a mistake… This automates it all.</p><p>You can go quite far and have consecutive stages; again if we keep our Christmas theme, we could make an advent calendar like the display on a CMS page. Every day the page would automatically update. You can even see a preview of the page at a given stage which allows you to validate your changes.</p><p>There are of course a few limitations to this feature, one of them is timezones. If your website is selling on multiple timezones and you wish your changes to take effect on the timezone in question you won’t be able to do it. There are a few ways around this but it requires a lot of duplications and still has limitations.</p><p>The second issue comes from the way the data is stored. So let us see how the staging works in order to understand the issue.</p><h3>How are the stages stored?</h3><p>Magento uses EAV to store its values, so the name of a product for a certain store will be stored as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/1*arhADY1mFJBfI5Wkg3tE7A.jpeg" /></figure><p>This basically means product “4” has one entry in the <em>catalog_product_entity </em>table and multiple entries in the <em>catalog_product_entity_varchar </em>table to store all the text values.</p><p>When the staging modules is enabled the structure changes,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*iuTvgGpeRpX85XMgkzPp6w.jpeg" /></figure><p>The <em>catalog_product_entity</em> table changes quite a lot; we have 3 new columns added to the table. <strong><em>entity_id </em></strong>is no longer the primary key of the table, now it’s <strong><em>row_id. </em></strong>This means there can be multiple rows for the same product. The <strong><em>created_in</em></strong> &amp; <strong><em>updated_in </em></strong>columns allow us to load the “proper” stage at a given time.</p><p>Let us also note the values store in the varchar table has also been duplicated for each row. So instead of having one value per product, we have one value per product &amp; version. Which seems logical.</p><p>With staging, all queries to products are automatically added a new condition :</p><p><em>((main_table.created_in ≤1615385079) AND (main_table.updated_in &gt; 1615385079))</em></p><p>With this, all queries using the product collection will load a product only once even if it has multiple stages. How come? If we have a stage that starts the 24th and ends the 25th the base stage that starts at 1 and never ends the query should find both?</p><p>Yes, that is why the “main” stage is split into 2 in the database:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/793/1*R03nLcNB5ZTpDw9WGwAv1g.jpeg" /></figure><p>So, we have 3 duplicates of the product stored in the database. This allows the stages to work quite efficiently on the frontend. But how does edition works?</p><p>Let’s say we created our stage “Christmas stage” and we are still on the 21 of December. We now fix something on our product; the changes are made to the first stage that starts at 0 and ends the 24th? And when the 25th arrives our changes disappear? No there is an additional table, <strong><em>staging_update</em></strong> which links these “periods” in the database between each other. So when you edit the “Main Stage” it will in the database update entries for the 0–24th period and also the 25th to infinity period.</p><p>You probably are starting to see the problem here. But first, let us see how the search will be affected.</p><h3>Why is the database structure such a problem?</h3><p>The problem arises when you start having a lot of stages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*ixJjwXTD09tFQL_ZMIb2BQ.jpeg" /></figure><p>We have 5 stages, yet in the database, the data is duplicated 9 times. That means that ((2 * nb_stage) -1) entries in the database. So we are duplicating data in the database which we know is a bad practice and I don’t think needs time explaining here.</p><p>The second issue is more practical; it arises when we try to save the product. The more stages you have the more the “Main Stage” becomes fragmented and hard to update; making the save operation on a product slower and slower.</p><p>Finally, there are not cleanup methods, once easter is passed we could imagine deleting the old stages and remove some of the duplicated data. There is nothing doing this natively.</p><h3>Technical</h3><h4>How is query altered</h4><p>As said earlier all queries on stagable entities are altered, this is done with a from rendered added by the staging module (magento/module-staging) with the class <em>Magento\Staging\Model\Select\FromRenderer</em>.</p><p>If you wish to prevent this condition to be added to your query, you can do so by adding the following code:</p><pre>$select-&gt;setPart(&quot;disable_staging_preview&quot;, true)</pre><p>You rarely need to do so; unless if you are trying to actually get the data for all the stages with one query.</p><h4>Search &amp; Indexation</h4><p>The staging functionality will not alter any of the index tables, or the elastic indexes. Instead, we have a new cron “staging_apply_version”. This will search for all stagable entities that need to be reindexed.</p><p>This introduces a second limitation, if a lot of entities needs to switch at a given time the indexes will be late, for their update will take a lot of time.</p><h3>Conclusion</h3><p>The staging modules of Magento can be really useful, more so on less complex objects such as CMS pages or price rules. If your database is relatively small it can also safely be used on products and categories.</p><p>My main issue with it is that it’s installed by default in the Commerce Edition of Magento it should have been optional for integrators to install. The module modifies the database structure extensively, which means it can not be easily removed once installed. So better install it only when needed. A lot of projects has the modules installed and enabled without reason, often developers working on the website don’t take it into account which results in errors when it is actually used. So it’s prone to create bugs.</p><p><em>Edit 1: Added additional information on where in the code the queries are altered for stagable entities as well as information on how to disable it. I also added some information on how the indexation(search) is affected by the stages.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=985b393a8fc5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/magento-commerce-staging-what-it-is-and-its-dark-secret-985b393a8fc5">Magento Commerce- Staging — What It Is and Its Dark Secret</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should have at least one middleware with your E-Commerce]]></title>
            <link>https://oliverde8.medium.com/why-you-should-have-at-least-one-middleware-with-your-e-commerce-3f12cabf03f9?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f12cabf03f9</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[magento]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Wed, 20 Jan 2021 07:35:16 GMT</pubDate>
            <atom:updated>2021-01-27T16:19:16.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>Don’t stuff your e-commerce with all the logic, split it up for stability, performance, security and maintainability.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Wcxhu8UmsUNvdZViPYw1aw.jpeg" /><figcaption><a href="https://pixabay.com/illustrations/lightbulb-bulb-light-idea-energy-1875247/">Pixabay</a> — Idea</figcaption></figure><p>This is quite an old subject of mine, one that I have trouble explaining to my clients. Often we are migrating from a Magento1 website, they are used to having all the development done in their monolith e-commerce solution. When they migrate to a new solution they expect to keep the same logic.</p><p>Times changes and we got more experience in building e-commerce websites. E-commerce websites are also more important for business then they used to be; their share in most companies income increases day by day. The current context with pandemic and restrictions have accelerated this even more.</p><p>The tendency today is for headless websites, with microservice architecture. But this is not possible for everyone; it’s still quite new and expensive; there are also very few ready to use software to make your e-commerce in such a manner.</p><p>Most websites even today end up therefore to rely on monolithic apps such as Magento, or Sylius. These applications are more flexible then ERP’s on which most, if not all the business of the company depends. The flexible e-commerce solutions, therefore, grows even more as more logic are added to them.</p><p>It is my opinion and experience that some of these logics can be externalised into an additional software that would be called a middleware. This is made easily possible by the new e-commerce software all supporting rest api’s natively.</p><h3>First, What is a middleware?</h3><p>Middleware is a very loose term, but basically, it’s a piece of software between 2 other pieces of software. Software <strong>A </strong>can’t communicate with software<strong> B; </strong>a middleware in between will allow them to communicate.</p><p>In someways a middleware is a translator, you speak English only, you need to talk to someone that speaks French only. There are 3 solutions:</p><ul><li>You learn French.</li><li>The other person learns English.</li><li>You hire a translator.</li></ul><p>The middleware is the third solution. Sometimes it’s good to learn a new language but can you learn 10 new languages? Do you have the time to learn 10 languages?. T</p><p>Of course, a translator is not as good as having 2 people speaking directly with a common language because of communication issues. Even so, if you do learn a new language but are not fluent enough there might be miss understandings as well. The translator is simply the fastest and most efficient solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*p2iPszBTKrgp4dxVG4xFAg.jpeg" /></figure><h3><strong>What can we do with a middleware?</strong></h3><p>Before seeing exactly how a middleware can help us let’s see an example of what a middleware can do for your e-commerce.</p><p>Your e-commerce usually needs to fetch products or at the very least the product stocks from an ERP. It will also need to export the orders to an ERP and synchronise the status of the order with the ERP.</p><p>The EPR already has api’s or file exports that allow external applications to communicate with it. The e-commerce solution also has such api’s.</p><p>Now the middleware can sit in between both these applications and call the ERP’s and the e-commerce solutions api’s. It can also do transformations, do additional checks, send report mails; it all depends on what you need.</p><p>So why should we use a middleware instead of doing custom code in the e-commerce solution?</p><h3>Advantages of a Middleware</h3><h3>Stability</h3><p>Not having the code for connecting the ERP to the e-commerce in the e-commerce, means less code in the e-commerce solution. Which means fewer chances for :</p><ul><li>the need to redeploy a new version of the e-commerce solution, which is always risky</li><li>new code added to affect your customers and therefore your sales</li></ul><p>Also, If the middleware fails your customers and your sales won’t be affected. You will continue to sell; you might just end up having some longer processing times.</p><p>Separating the code from the e-commerce solution doesn&#39;t make everything more stable, but it makes the most important part; the visible part of the website more stable. If your e-commerce is down for even 1H; during Christmas that is a nightmare; if the middleware is down, that is manageable.</p><h4>Performance</h4><p>Also, some e-commerce solutions will slow down as more code is added to them; even if that particular code is not executed in a particular page. In the case of Magento for example, this is mostly due to divers cache containing data from all the modules. So having less code in Magento will also increase performances.</p><h4>Flexibility</h4><p>A Middleware can also be very easily duplicated; imagine you are migrating to a new ERP, and a particular low traffic low sales country migrates before the others in order to test the new ERP.</p><p>You can easily deploy a new version of the Middleware while still keeping the old one running. Both could run at the same time; the old version continues to sync countries connected to the old ERP, and the new one the other countries. Once all the countries are switched to the new ERP you just throw away the old middleware.</p><p>With today&#39;s flexible hosting solutions having multiple instances is a breeze. There are multiple scenarios where this can be used. And of course, all these changes can be made with 0 risks for the customers visiting the website.</p><h4>Maintainability / Security</h4><p>Depending on your business model you e-commerce solution might not have a dedicated development team working on it full time. You are happy with your solution and do not need to make changes often. This does not mean you must not keep the solution up to date. The e-commerce application is exposed to the public and therefore to attacks. You must therefore update your solution constantly.</p><p>At each update even minor the development team will need to adapt code to make it compatible with the new version(particularly with Magento), and you will need to test the new release. The less code you have the faster you will be able to make these security updates and the less time your website will run in a vulnerable state.</p><p>The middleware is less concerned by security attacks, ideally, the middleware is not exposed to the public at all; and it’s also very improbable the middleware is storing any data. This means that security updates for the middleware are less critical and can be done less frequently.</p><h3>Cons to a Middleware</h3><p>There are 3reasons I can think of for not having a middleware:</p><ul><li>The development team looking after the project will have to master 2 “technologies”. The e-commerce and the middleware. This is half true, a middleware as described is usually very simple; the complex part is the business part. It’s my belief that any good developer should be able to jump into such a tool. <br>If you are using sylius for example, this is actually not even true because both the e-commerce solution &amp; the middleware would be based on Symfony.</li><li>Additional hosting costs; this is more relevant. If you are using a modern hosting solution you can actually even use lambdas for executing the middleware which makes them cheap. We could install the middleware on the same server as the e-commerce solution but that’s not ideal as you would add common version dependencies between both application which would make maintenance more complex.</li><li>Added complexity to the architecture.</li></ul><h3>Conclusion</h3><p>In my opinion, these cons are non-issues, and any additional cost or the additional architectural complexity pays for itself very quickly.</p><p>There are very few reasons to develop connectors directly inside your e-commerce. Sometimes you might need to do it for performance if the native api’s doesn’t allow you to do bulk operations.</p><p>I have recently worked on a project for a new client, to connect a Magento that is at its end of life to an ERP. The deadlines were very short and we didn’t have access to the source code of the Magento as we were supposed to. We were nevertheless able to create the connector and deploy it. Because we used a middleware not having access to source code of the Magento didn’t affect us. There were custom devs but the api’s allowed us to find the information we needed without us having to do possibly false suppositions on how the data was stored.</p><p>The trick is to split things correctly, to remain in budget and not over complexify things for projects that possibly will never have dedicated development teams for their maintenance. So sometimes it’s better to put multiple things in one middleware then split them into multiple middlewares. These choices are very situational.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f12cabf03f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Reasons as a shop owner you shouldn't use Magento]]></title>
            <link>https://oliverde8.medium.com/5-reasons-as-a-shop-owner-you-shouldnt-use-magento-cd860adcb74f?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd860adcb74f</guid>
            <category><![CDATA[magento-2]]></category>
            <category><![CDATA[online-shopping]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[magento]]></category>
            <category><![CDATA[ecommerce]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Mon, 23 Nov 2020 08:04:02 GMT</pubDate>
            <atom:updated>2021-01-20T13:27:30.573Z</atom:updated>
            <content:encoded><![CDATA[<h4>Magento has been the reference for making an e-commerce website. But things change</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*Vxi_Qtkir0vLXzJc84lhdg.jpeg" /></figure><p>Those who know me know very well that I don’t like much Magento. I have been working with Magento1 for the last 6 years and worked on Magento2 websites since it was published.</p><p>In my opinion, there are multiple technical reasons why Magento2 is a failure, and I have written a few articles on this subject.</p><p><a href="https://medium.com/@oliverde8/magento-2-a-dead-giant-22ed25020a6e">Magento 2 — A dead giant?</a></p><p>But in this article, I will give you 5 reasons <strong>why as a shop owner you should not use Magento2.</strong></p><h3>The reasons</h3><h4>1 — Native bugs</h4><p>Magento 2 has a lot of bugs, in the CE and the EE edition. This can easily bee seen in their GitHub</p><p><a href="https://github.com/magento/magento2/issues">magento/magento2</a></p><p>A lot of these issues are actually people asking support, but there are also a lot of true issues that will affect your e-commerce. For example, this bug <a href="https://github.com/magento/magento2/issues/3625">#3625</a> which can cause the price displayed in the mini cart to be wrong. The bug was submitted in 2016 and confirmed on Magento 2.0. This bug is still present in magento 2.4.</p><p>There are also bugs with payment methods which can charge incorrect amounts (see <a href="https://github.com/magento/magento2/issues/7977">#7977</a>), as well as calculations errors (see <a href="https://github.com/magento/magento2/issues/8964">#8964</a>) which can lead to customers not paying the correct price. These are only a few examples among many.</p><p>Finally, there are these bugs that are ignored. For example, the “Maximum qty discount” option on cart rules don’t work since Magento 2.1. The issue (see <a href="https://github.com/magento/magento2/issues/9214">#9214</a>) exists but has been closed as they will not fix it.</p><p>What does this mean for you a shop owner?</p><ul><li>Any configuration or <strong>contribution</strong> should be tested on a test server before. I would recommend testing configuration changes on a test server for most solutions, but with Magento, I recommend testing contributions as well. This is very time-consuming.</li><li>You will need to find workarounds or install modules that fix native bugs or have your developers try and fix these native issues. Even workarounds will take time.</li></ul><p>This means you will have additional expenses that you can’t foretell because you can’t trust your solution. It also means you will have to make compromises.</p><h4>2 — Performance</h4><p>Magento advertises Magento 2 as faster then Magento1. First of all, this is wrong. Magento 2 can be in some cases faster than Magento 1. The way Magento works, once a page is displayed it will cache its content. So next time the page will display faster. Magento2 supports Varnish which Magento 1 didn’t; thisis great for performance. This is why Magento advertises Magento2 to be faster.</p><p>The issue is, what happens if the page isn’t yet in cache? The page is very slow, it’s actually slower then Magento1. Let’s also note that some pages can’t be in cache, their content changes for each user; these pages will always be slow.</p><p>Another performance aspect is on the client-side. There as well, Magento is very slow. There is a lot of Javascript &amp; Css loaded on every page; the HTML is also very heavy.</p><p>Can you make things better; yes you can, but it will cost a lot.</p><ul><li>First You need to put Magento on a diet. This means removing all the modules you don’t use. This is complicated because most modules are essential and finding those that can be removed without breaking Magento is time-consuming. You will also need to spend time to check it after each update.</li><li>You need to create a theme from nothing. Need to remove (by override) all the native layouts and content in order to start from scratch. This also means that you will lose some of the flexibility Magento offered and the install of each new module will be more complicated.</li></ul><p>For a few years now Magento has started recommending PWA applications. This fixes Magento being heavy on the client side but:</p><ul><li>PWA is still a young, and therefore costly to put in place and to maintain.</li><li>PWA does not fix Magento being slow to respond. Magenot’s API which allows PWA implementation are also very slow.</li></ul><p>All of this means that you can’t expect to have a perfect SEO, for performance plays an important role; this also means you will spend a lot of time on performance subjects and/or on building a PWA application.</p><h4>3 — Hosting</h4><p>Magento used to rely on Mysql for search. Mysql is not a search engine. It can’t handle properly fixing typo’s and it can’t do facet’s in an efficient manner. Magento has therefore added support for Elasticsearch. This is great, but they have made Elasticsearch mandatory.</p><p>Magento also uses queues to handle heavy operations. Importing a large file, for example, will run in the background so that the admin that executed it can continue to work. This at first was handled with Mysql. Mysql is not designed to handle queus; its not efficient. Magento, therefore, added support for Rabbitmq which is great, but they have made RabbitMq mandatory</p><p>Having both Elasticsearch support &amp; RabbitMq is great if you have thousands of products and if you are constantly running imports and other heavy operations. But most stores don’t need RabbitMq; some doesn&#39;t even need Elasticsearch.</p><p>By adding new services that are mandatory Magento is increasing the hosting costs. Magento being also very heavy requires powerful servers that also adds to the cost.</p><h4>4 — The Admin Panel / The Back Office</h4><p>From the Magento’s back office you can edit your product structure, you can edit the products, handle your order flow, change configurations. The Back Office does everything it is expected todo.</p><p>But, it is also very slow; if you have multiple categories you can need a few minutes to see the page. If you have complex products the product page can freeze your computer when opening and sometimes even crash your browser.</p><p>If you only have a few products, and a few orders this is fine; but if you intend to manage thousands of products directly in Magento you will lose a lot of time.</p><h4>5 — False Enterprise Edition Support</h4><p>If you are thinking of using Magento Enterprise Edition, you might think that you won’t be concerned by some of the Magento issues. That might be true if you use a Magento with 0 customisations. But if you add a single extension you will need to prove that a native Magento has the same issue. So again you will need to spend time.</p><p>Even once you proved them that the Bug is present on a native Magento you will need to wait for a lot for a fix; if you ever get one. And if you end up getting one there is a chance that at the next update your fix will stop working at the bug will be back. Once this happens you will need to start all over again.</p><p>So let’s make it clear, if you do think of getting an Enterprise Edition for their support; well in my opinion don’t. Get an Enterprise Edition for it’s features.</p><h3>Conclusion</h3><p>The main issue is that <strong>Magento has lost its identity;</strong> it used to be a great e-commerce solution for small and medium sized businesses.</p><p>Today small businesses can’t really use Magento. 5 years ago having a mediocre website was acceptable; today it’s not. So a small business can’t afford to run a Magento without making a lot of compromises which means having a mediocre website. This is due to Magento has a lot of issues out of the box.</p><p>Medium businesses can use Magento, but at a great expense; and even they would need to make compromises.</p><p>So who is Magento destined to? The big businesses?. No, they can’t use Magento, because Magento won’t scale well. If you put 50 stores (languages) and 1 million products in Magento it won’t hold. Cart prices rules will fail, the Back office will not work properly, imports &amp; exports will not run and even if it worked, performance would always be an issue.</p><p>So who can use Magento? Well, those just in between the big businesses and the medium ones. Those who sell enough online to justify the cost of Magento and that needs most of the Magento features. Those who can make compromises but don’t have the budget for something that would cost more but would work better.</p><p>Magento2 has tried to change segments; to aim at a richer market. They did this by adding new features, supporting new stacks; but at the bottom the foundations they are not designed to handle it. This failed attempt has worsened Magento; it has made Magento expensive and even more complicated than before.</p><p>With alternative solutions growing and becoming easier to use for both the shop owners and for the developers, there are fewer arguments to choose Magento every day.</p><p>Thanks for reading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd860adcb74f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Comparison of Log Aggregation & Analysis Tools]]></title>
            <link>https://medium.com/swlh/comparison-of-log-aggregation-analysis-tools-f45f27fd24c2?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45f27fd24c2</guid>
            <category><![CDATA[datadog]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[logging]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Wed, 21 Oct 2020 11:54:10 GMT</pubDate>
            <atom:updated>2020-10-21T14:38:15.951Z</atom:updated>
            <content:encoded><![CDATA[<h4>Logs tell us important stories, but they also ramble a lot. If we can’t find a log it is as if we didn’t log it.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/735/1*jLZ3lDEYOF74XSzT04Nz5Q.jpeg" /><figcaption><a href="https://imgflip.com/i/4ig3oc">https://imgflip.com/</a></figcaption></figure><p>In my last 2 articles about maintenance, we have talked about properly <a href="https://medium.com/@oliverde8/maintainability-handling-exceptions-properly-fffdd7a95a65">handling exceptions</a> and <a href="https://medium.com/swlh/maintainability-logs-their-use-6ac3bb235e31">how to log properly</a>. Both subjects are simple enough, but done improperly will make our application unmaintainable.</p><p>In this article, I won’t explain how to configure these log aggregation and analysis tool. We rather are going to see the difference between the various tools I have tested. This way we can choose which tool we wish to have. There is plenty of tutorials on how to set up the tools.</p><h3>Why aggregate logs</h3><blockquote>If we can’t find something it is as if we didn’t have it.</blockquote><p>It is true for things we own, it’s also true for logs. For most small applications we can search and find logs using a simple grep command on the server. Most often this is enough. But when we start having multiple files and multiple servers, with thousands of users, finding the right log might start to become a problem. <strong>Log aggregation will help us find these logs.</strong></p><p>Errors/Exceptions; are usually easy to find; because we often have one error repeating itself; or a single error log that’s easy to find. In this case, finding the log and fixing the issue shouldn’t be hard. But this means that either someone checks our error logs manually, or someone has noticed the error and is complaining. <strong>Log aggregation will allow us to see if there have been any errors and with some tools even alert us.</strong></p><p>What aggregation also allows us to do, is statistics. As discussed in a previous article, this will allow us to understand the impact of a particular error or log. If our website registers thousands of orders per day and we have a single order in error; even if the error is important the issue is not critical.</p><h3>How to aggregate logs</h3><p>There are 3 steps to log aggregation:</p><ul><li>The first step is to have a storage solution. We can’t just store logs in files anymore; we need something more. In this article, we will discuss 3 solutions. <a href="https://www.elastic.co/fr/elasticsearch"><strong>Elasitcsearch</strong></a>, <a href="https://grafana.com/oss/loki/"><strong>Loki </strong></a>&amp;<strong> </strong><a href="https://www.datadoghq.com/"><strong>Datadog</strong></a></li><li>The second step is to tail the logs to send it to our storage of choice. This step could be removed if the application sends its logs directly to our storage. I have never used this technique as I don’t think that the application should depend upon another service for logs. I rather use a tailing agent that reads the log files written by the application. We are going to talk about 3 solutions for this; <a href="https://www.elastic.co/fr/beats/filebeat"><strong>Filebeat</strong></a>, <a href="https://grafana.com/docs/loki/latest/clients/promtail/"><strong>Promtail</strong></a>, &amp; <a href="https://www.datadoghq.com/"><strong>Datadog Agent</strong></a></li><li>Finally, we need a visualisation tool, a tool that allows us to easily search the logs, make statistics and even alerts. 3 other solutions are present here; <a href="https://www.elastic.co/fr/kibana"><strong>Kibana</strong></a>, <a href="https://grafana.com/"><strong>Grafana </strong></a>&amp; <a href="https://www.datadoghq.com/"><strong>Datadog</strong></a></li></ul><p><strong>Datadog </strong>is a SASS tool that takes care of both the visualisation and the storage. It is plugged to the Datadog agent that fetches the logs (and other metrics) on the server it is installed on. Most of the configuration is done directly in the interface once the agent is installed.</p><p><strong>Elasticsearch</strong>, <strong>Filebeat </strong>and <strong>Kibana </strong>are all 3 tools made by Elastic.co.</p><p><strong>Loki</strong>, <strong>Promtail </strong>and <strong>Grafana </strong>are all 3 tools made by Grafana.</p><p>We actually can intermix the Grafana &amp; Elastic.co solutions. Datadog stands apart as a SASS solution. Grafana can use both Loki and Elasticsearch as a data source but some features are more limited when using elastic search.</p><p>Before continuing I would like to point out that I am going to compare these tools from the perspective of a developer and not a DevOps. Loki for example has a few compromises that will allow it to be lighter to host compared to an Elasticsearch.</p><p>Also, for the second step of tailing the logs, there are more generic solutions such as <a href="https://www.fluentd.org/"><strong>Fluentd</strong> </a>that can be used to populate both Loki &amp; Elasticsearch.</p><h3>Our contenders</h3><p>The software used to tails the logs has little impact on the final results and as we are focusing on the developer aspect we will ignore them.</p><p>Our contenders are :</p><ul><li>Elasticsearch for storage &amp; Kibana for visualisation.</li><li>Elasticsearch for storage &amp; Grafana for visualisation.</li><li>Loki for storage &amp; Grafana for visualisation.</li><li>Datadog.</li></ul><h3>Comparison</h3><p>Here we can see a list of features and the support for these features by the combination of our tools. Let’s look closer.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd6f32688811f370e839beb0528cc77e/href">https://medium.com/media/dd6f32688811f370e839beb0528cc77e/href</a></iframe><h4><strong>Parsing context</strong></h4><p>Logs contain multiple information, a date, a level, a message. It also should contain a context. This context is what gives meaning to the log. If an order can’t be captured we should log “<strong>Order can’t be captured</strong>” and put the order id as well as any additional information in the context.</p><p>It is therefore important to be able to read the data but also to parse it so that we can query it and use it instead of it just being a string where all the data is dumped. If you use Monolog in php this will be a json at the end of the log.</p><p>All the tools we tested with the proper configuration will allow the information to be accessible.</p><ul><li>For Elasticsearch used file beats we need to add an ingest.</li><li>For Loki, it needs to be parsed by the tailing agent</li><li>For Datadog this is done directly in the applications web page.</li></ul><h4>Dynamically taking context into consideration</h4><p>Our storage solutions require to be configured to make use of our fields in the context. For example, we need to define “order_id” as an int.</p><ul><li>For Elasticsearch + Kibana this can be done very easily through the interface. A button even allows the mapping to be updated automatically based on the existing data.</li><li>For Grafana with Elasticsearch, it’s slightly more complicated. We will need to make a query manually to Elasticsearch to update the index configuration.</li><li>For Loki and Grafana, you need to change the configuration of the tailing tool. Which makes it the harder of the 4 to configure. To add to the complexity fields extracted from the context can be just “visible” or filterable depending on the configuration.</li><li>For Datadog, this can be easily configured on their website.</li></ul><h4>Taking context into consideration for older logs</h4><p>Does changing the configuration affect older logs? This can an interesting feature if we forgot to update our tool after adding additional data in the context.</p><p>This feature is directly related to the storage solution.</p><p>Both Loki &amp; Datadog will take the new “mapping” into account for new logs only.</p><p>Elasticsearch on the other hand will do the changes on all the logs of the current index. This means(depending on your configuration) for logs written the same day. But you can force it on the older indexes if you need it, but that will require you to manually do queries.</p><h4>Searching logs with keyword</h4><p>All of our tools have dedicated interfaces for searching through logs.</p><p>The only exception is the combination of Grafana with Elasticsearch. Grafana’s log exploration interface is only compatible with Loki.</p><p>Grafana’s interface is also less practical in my opinion. In requires us to have at least one filter element in place. It limits the number of results making it difficult to zoom into a particular timeframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*qA-Tap9ZuovFJ09qcq01JA.png" /><figcaption>The graph’s in Grafana are “truncated”.</figcaption></figure><p>In this particular example, we might think that there are nogs logs before 11h45. That’s not true it’s just that the graphic displays only the last 1000 logs.</p><p>By comparison, Kibana will show a complete graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*7e8GV4_vQdeDWJ0e8NiH6Q.png" /><figcaption>Kibana on the log search page showing a complete graph of all logs.</figcaption></figure><h4>Searching logs with precise search terms from the context</h4><p>Beside our Grafana &amp; Elasticsearch duo; all tools allow us to search in data from the context. For example, we can find all logs concerning a certain order.</p><p>Once again Grafan’s interface is lacking. Datadog &amp; Kibana, both have facets that make seeing the values that might concern us much easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*SVfQFDXHNwYhlQkpwoyDyw.png" /><figcaption>The Kibana facet view is very useful</figcaption></figure><p>We can quickly see information from our context. And can add filters to narrow our search.</p><p>So even though Grafana allows us to filter data it doesn&#39;t give us this facet view that makes applying filters easier.</p><h4>Visualizing logs with graphs</h4><p>Visualising log rates with a graph can be practical to understand the error by bettering visualising its occurrences. It can also allow us to better assess the criticity of the error.</p><p>For example, Magento logs every time it purges a cache from varnish. This can allow us to diagnose slowdowns.</p><p>All three of our solutions allows us to make such graphs.</p><h4>Creating graphs from context data</h4><p>We can visualise the error rate but what if we could use the context data as well for our graphs. For example; on an e-commerce website we could visualise the number of errors per country.</p><p>According to the documentation, it’s not possible to do this with Loki &amp; Grafana. But the feature is currently being developed and it’s actually possible to use.</p><p>This can be done by configuring the Loki server as a Prometheus data source in Grafana. So the Loki data source is configured 2 times. Even though this works; I encountered a lot of issues with the Prometheus queries:</p><ul><li>There are different behaviours, valid Prometheus queries don’t always work.</li><li>All Prometheus aggregations have not been implemented.</li><li>The aggregations don’t work correctly. It gives a good view of what’s on with the order of magnitude visible. But the exact numbers don’t always match.</li><li>Random errors that go away by re-executing the same query a few seconds later.</li></ul><p>Grafana with Elasticsearch works very well; as well as Kibana. Datadog has a few limitations as some graphs can’t use context data but is still a strong contender.</p><h4>Alerting from aggregations</h4><p>Now that we have graphs we could use the aggregations to automate alerts. This is can be a quick and dirty way of making a critical problem manageable.</p><p>If we have shipping issues for example for 1 order nearly every day. If we can alert the person responsible and give him the necessary information; he can then contact the client, manually fix the order until we fix the issue properly. It gives us alternatives; it gives us time.</p><ul><li>Grafana allows us to configure alerts with both Elasticsearch &amp; Loki. When using Loki, as for graphs, we will need to configure it as a Prometheus source for the alerting to work.</li><li>Datadog allows alert’s as well.</li><li>Kibana has no alerting.</li></ul><h4>User accounts</h4><p>Finally the possibility to create accounts and limit user privileges. This is interesting when we have people of different profiles checking our tools. Our client for example might have his own dashboard that he manages and we have our own that he can see but not modify.</p><ul><li>Grafana is the most complete solution; we could even use a single Grafana for multiple clients/websites and separate accesses properly. Permissions can be configured per dashboard and also per source.</li><li>With Datadog we will be able to have multiple accounts but we can’t set up permissions per dashboard. So our client would have read-only access and we would need to create graphs and dashboard for him if we wish to prevent him from changing our own dashboards.</li><li>Finally; Kibana. Kibana has no user support. By default, it’s public and everyone can connect to it. We can add some privacy by putting it behind a proxy but there won’t be a per person permission setup.</li></ul><h3>My opinion</h3><p>If we do not want to use a SASS solution; I think Kibana + Elasticsearch is the easiest to set up and is the most practical. Kibana’s interface for searching is very good, and creating graphs is easy. Nevertheless, it’s missing 2 important features:</p><ul><li>User accounts</li><li>Alerting</li></ul><p>Therefore if we need one of these features I would also add a Grafana. In which case we would only use Kibana to configure the indexes &amp; to search the logs and use Grafana for the graphs and the alerts.</p><p>If we have the budget and are okay to use a SASS solution; I think that Datadog is very easy to install and it’s pricing is very reasonable.</p><p>Thank you for reading</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45f27fd24c2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/comparison-of-log-aggregation-analysis-tools-f45f27fd24c2">Comparison of Log Aggregation &amp; Analysis Tools</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maintainability — Logs & Their Use]]></title>
            <link>https://medium.com/swlh/maintainability-logs-their-use-6ac3bb235e31?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac3bb235e31</guid>
            <category><![CDATA[monolog]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Tue, 22 Sep 2020 10:39:38 GMT</pubDate>
            <atom:updated>2020-09-24T16:29:14.339Z</atom:updated>
            <content:encoded><![CDATA[<h4>Maintenance 102</h4><h3>Maintainability — Logs &amp; Their Use</h3><h4>An application that logs properly will make maintenance easier.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/717/1*_OaNpSzU4YD2PLsjFGfI2Q.jpeg" /></figure><p>In the first chapter, we saw how to handle exceptions and how to log them to:</p><ul><li>not leak sensitive data to the user.</li><li>have user user-friendly messages displayed for your users.</li><li>have all the details for easy troubleshooting.</li></ul><p><a href="https://medium.com/@oliverde8/maintainability-handling-exceptions-properly-fffdd7a95a65">Maintainability — Handling exceptions properly.</a></p><p>In this second article, we will see what needs to be logged beside exceptions, how to log them, and why we are logging them.</p><p>The examples in the article are in <strong>PHP</strong>, using the <a href="https://www.php-fig.org/psr/psr-3/">PSR-3: Logger Interface</a>; but the logging concepts we will discuss are common to all languages.</p><h3>What to Log &amp; How to Log</h3><p>To decide what needs to be logged, we must first decide why we are logging the information.</p><ul><li>Most often we need to log information <strong>to make diagnostic easier</strong>. For example, if an API returns an error we will log the request &amp; response.</li><li>We also log to<strong> for debug purposes</strong>, For example, we might log all api requests &amp; responses in order the debug the api endpoint.</li><li>We can also log<strong> for statistics</strong>; this can be used for various reasons.</li></ul><h4>Logging for diagnostic</h4><p>The most important log for diagnostic is the exception logs; those we have already discussed previously. But we can also log other “errors” for all errors are not exceptions.</p><p>One of the best examples of this is API calls; there are other cases as well; a missing file; an empty database query…. The cases depend upon your application.</p><p>Let’s see an example with an api call</p><pre>&lt;?php</pre><pre>$response = $this-&gt;httpClient-&gt;get($endpoint, $query);<br>if ($response-&gt;getStatusCode() != 200) {<br>    $this-&gt;logger-&gt;warning(<br>        &quot;Failed to fetch test data from test api&quot;, <br>        [<br>            &quot;endpoint&quot; =&gt; $endpoint, <br>            &quot;query&quot; =&gt; $query, <br>            &quot;status_code&quot; =&gt; $response-&gt;getStatusCode(), <br>            &quot;body&quot; =&gt; $response-&gt;getBody()<br>       ]<br>    );</pre><pre>    throw new MyApiException(&quot;Failed to fetch data from test api&quot;);<br>}</pre><p>In this example, we logged everything we need to make the same api call locally to check what is going on. We also used a unique log message so that if we find the log message in our logs we can find the code that has logged it.</p><p>So the point here is to :</p><ul><li><strong>Log what you need to reproduce the error locally and you can’t get by any other means.</strong></li><li><strong>Log what you believe will allow a quick diagnostic (The body)</strong></li><li><strong>Log a unique message that has meaning.</strong></li><li><strong>Do not log every step of the code!</strong></li></ul><p>You need to keep in mind not to log sensitive data such as passwords.</p><h4>Logging for Debug</h4><p>Logging for debugging is very similar to logs for diagnostic. If you have api’s that are very sensitive and you can’t make api calls locally easily(payments for example). Or you do not trust the api. It can be a good idea to log everything.</p><p>Let’s add debugging data to our previous example;</p><pre>&lt;?php<br>$this-&gt;logger-&gt;debug(<br>    &quot;Fetching test data from test api&quot;, <br>    [<br>        &quot;endpoint&quot; =&gt; $endpoint, <br>        &quot;query&quot; =&gt; $query, <br>   ]<br>);</pre><pre>$response = $this-&gt;httpClient-&gt;get($endpoint, $query);<br>if ($response-&gt;getStatusCode() != 200) {<br>    $this-&gt;logger-&gt;warning(<br>        &quot;Failed to fetch test data from test api&quot;, <br>        [<br>            &quot;endpoint&quot; =&gt; $endpoint, <br>            &quot;query&quot; =&gt; $query, <br>            &quot;status_code&quot; =&gt; $response-&gt;getStatusCode(), <br>            &quot;body&quot; =&gt; $response-&gt;getBody()<br>       ]<br>    );</pre><pre>throw new MyApiException(&quot;Failed to fetch data from test api&quot;);<br>}</pre><pre>$this-&gt;logger-&gt;debug(<br>    &quot;Fetched tes data from test api&quot;, <br>    [<br>        &quot;endpoint&quot; =&gt; $endpoint, <br>        &quot;query&quot; =&gt; $query, <br>        &quot;body&quot; =&gt; $response-&gt;getBody()   ]<br>);</pre><p>Here we have added 2 additional logs:</p><ul><li>The first log is before making the call to the API. We log all the information we have at that point to be able to execute the same call locally if possible, or comparing with working calls.</li><li>The second log has the response, if we are working with payments this might be the only way to see a complete response. (Some payment methods have additional information on the production they don’t have in the sandbox).</li></ul><p>So the point here is to :</p><ul><li><strong>Log what we do.</strong></li><li><strong>Log the result.</strong></li></ul><p>Like in the previous case you need to keep in mind not to log sensitive data such as passwords.</p><p>We also have another trick up our sleeves here. In our previous example we logged using “warning” here we used “debug”. With most frameworks (Magento 😥) you can configure the level that should be logged. Constantly logging debug information is useless. So you need to enable/disable these logs when needed.</p><p>To be able to use this in symfony for example; I would recommend having multiple channels set up and have our custom channels use custom handlers. That way we can easily enable disable the debug logs for a given part of the application.</p><p><a href="https://symfony.com/doc/current/logging/channels_handlers.html">How to Log Messages to different Files (Symfony Docs)</a></p><h4>Log for Statistics</h4><p>Finally, we can also log to do statistics. This is possible if your logs are parsed and sent to tools such as Elasticsearch/Kibana, Elasticsearch/Grafana, Loki/Grafana, Datadog. On the third maintenance article, we will discuss more these tools and do a quick comparison. For now, let us just say that it is possible to use logs for statistics.</p><p>Our current logs can already be used to make statistics. For example, we can use the “Fetching data from test api” debug log to count the number of calls made to the API. This can be important information.</p><p>The only thing we would need to change is to increase the log level from debug to info.</p><p>There is also another usage for statistics, lets use our previous example again. We can use the <em>“Fetching data from test api”</em> logs and the <em>“Failed to fetch test data from test api”</em> logs to have an idea of the fail rate of the api. If you are using Grafana you can also use this for alerting purposes.</p><blockquote>I recently had such a case on production; without touching the code we were able to add an alert for a specific case that was not documented in the api we were using. This allowed our client to communicate with their customers about the issue. Thanks to grafana theye were able to see all concerned customers and didn’t need to wait for a negative customer feedback. Meanwhile we exchanged with the api maintainers about the best approach to take to get around the issue.</blockquote><p>This means once you identify 1 isolated issue, you can quickly find if there are other similar issues. Communicate on the subject making the issue less critical.</p><p>Using logs for statistics is cheap in development time. In my opinion, every project should have some log parsing anyway, so using that parsing to make some statistics is very useful.</p><p>There are of course limits; you are probably logging way more information than you need for the statistics you are extracting. This can be a good thing as it can be used to add an alert you hadn’t thought about. But this also means you can’t just keep all the logs indefinitely. It would cost too much to store them all.</p><h3>Why are logs so important?</h3><p>All applications have bugs; bugs they inherit from the software they are based on (cf Magento), bugs coming from the infrastructure, bugs that you develop, bugs from the application you connect to… There are bugs somewhere.</p><p>So at some, you are going to have a problem to resolve.</p><p>Properly logging will hopefully allow you to get a better vision of the problem as fast as possible.</p><p>If you do have proper logs for your issue, this will allow you to take the following steps:</p><h4>Be retroactive</h4><p>Will allow you to communicate on the issue before customers notice it, or get too much frustrated by it.</p><p>For example, we have an issue on some orders that are not shipping because of api calls to the carrier endpoints failing.</p><p>If we can list the concerned orders we can communicate and allow our customers to plan better.</p><h4>Understand the impact</h4><p>You have identified the issue and started to communicate on the subject. Thanks to the logs you know the orders that are concerned and you can understand the impact.</p><p>For example, your website has 1000 orders per day and you discover that 1 order per day is having an issue. If it’s Friday 6 pm you probably wouldn’t want to fix the issue. it would risk the other 999 orders. And if something went wrong with your fix no one would notice it during the weekend.</p><h4>Understand the issue</h4><p>With the proper log, you get closer to understand the origin of the issue. Is our api call to the carrier in error:</p><ul><li>because of a mistake in the code</li><li>because of the proxy or another issue with the infrastructure?</li><li>because of the endpoint being unstable?</li></ul><p>The logs will most often not give you a straight answer but it will make debugging easier than having none.</p><h4>How to fix the issue</h4><p>We must now find a solution. The solution can be implemented in multiple steps.</p><p>In our example case, we can have at first a person manually shipping the orders. This might need to be done if the issue is long to fix. We know there is a single order per day and therefore doing this manually would be simple.</p><p>Step 2 would, of course, be to fix the issue.</p><h3>Conclusion</h3><p>Will you be able to put logs everywhere that needs it to be able to debug future issues? You won’t be able to. That is why you must not overthink it either.</p><p>I have rarely come across an application that logs too much. I have often complained about not having enough logs, particularly in payment modules.</p><p>Does that mean that you should log everything? No; this is a case I came across one project I worked on. Opening a single page created over 500 lines of logs. There were logs in conditions to trace what was happening, logs in loops… Removing all the logs allowed page load times to be divided by 3.</p><p>Debug logs can be used for particularly complex and critical bits of code. But those should be disabled most of the time. Writing a log has a cost. You are accessing the file system after all.</p><p>You must think of log rotation and deleting your logs. Depending on the situation you might need to keep some logs longer than others. Logs are not meant to be kept and you need a strategy to get rid of the old ones.</p><p>In this article, we have seen what to log, and what to log.</p><p>The issue is using grep to search in log files has its limits. Particularly if we wish to start searching in the context of the log and we search for correlations.</p><p>Grep’s main limit whoever is for sites that are hosted on multiple servers with load balancing. Logs will be distributed on the multiple servers which makes finding and understanding them harder.</p><p>That is why in the next chapter of maintainability we will discuss the various tools that are available to us to parse &amp; aggregate the logs to make them more accessible.</p><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac3bb235e31" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/maintainability-logs-their-use-6ac3bb235e31">Maintainability — Logs &amp; Their Use</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Maintainability — Handling exceptions properly.]]></title>
            <link>https://medium.com/swlh/maintainability-handling-exceptions-properly-fffdd7a95a65?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/fffdd7a95a65</guid>
            <category><![CDATA[php]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Tue, 08 Sep 2020 06:48:53 GMT</pubDate>
            <atom:updated>2020-09-22T10:41:47.046Z</atom:updated>
            <content:encoded><![CDATA[<h4>Maintainability 101</h4><h3>Maintainability — Handling exceptions.</h3><h4>Let’s see together why it’s important and how it can change the way you code.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*o_Yiw28Wt-3AjrKg7gosig.jpeg" /></figure><p>This is an article I wrote a few years ago on my personal blog after stumbling on a Pull Request that was accepted on <a href="https://www.akeneo.com/">Akeneo</a>. I wanted to revisit this article, as I still see this error often in code I review and even in software I use. I have tried to improve upon my first variation.</p><p>Let’s first see the Pull Request at the origin of this article; <a href="https://github.com/akeneo/pim-community-dev/pull/9315/files#diff-e3fba94813fe8a2f52eecc102e995c5fR61">PIM-7915: Display a modal on deletion error</a></p><p>This pull request adds a nice catch try.</p><pre>try {<br>    $remover-&gt;remove($group);<br>} catch (\Exception $exception) {<br>    return new JsonResponse([&#39;message&#39; =&gt; $exception-&gt;getMessage()], 500);<br>};</pre><p>This merge request dates from the 6th of January 2019; and the code is still present in the <a href="https://github.com/akeneo/pim-community-dev/blob/4.0/src/Akeneo/UserManagement/Bundle/Controller/GroupController.php#L104">4.0 version of Akeneo</a>.</p><p>Why am I bothered with this try-catch, what is wrong with it?</p><ul><li>The catch doesn’t catch a particular exception but <em>\Exception</em> so all exceptions will be caught. <br>I suspect that the purpose is to catch exceptions such as “Group couldn’t be deleted because it’s in use”. But the way it’s been coded we might end up catching a Framework exception or a database connection exception. <br><strong>First, issue: We do not know what we are catching.</strong></li><li>The exception message is also sent to the user; this can be done but only when we are aware of the messages we are going to show our users. <br>By catching all exceptions we might very well show him a database error such as <em>“Access denied for user ‘fakeuser’@’localhost’ (using password: YES)”<br></em>There is way too much information in that message for someone with bad intentions. <br><strong>Second issue: We do not know the possible error messages we are showing to the users and what information we might leak to users.</strong></li><li>Finally, there is no logging. This is acceptable if catching specific exceptions; but if it’s an unexpected situation we need to log the exception in order to be able to debug the issue. <br>The message displayed to the user has no value because the user might choose not to share it; and even if he does share it there is little context and no trace. Maybe just as we saved it the database server failed and it was an isolated situation. Maybe there is an error in our code that’s hard to reproduce there is no way to know (nginx/apache logs can be of help here).<br><strong>Third issue: We do not know how to fix the error.</strong></li></ul><p>So what should be done?</p><ul><li>Only catch exceptions you wish to catch, avoid catching \Exception as much as possible.</li><li>Show user messages from specific exceptions for which you know the messages. For other exceptions send the user a generic message.</li><li>Low-level framework exceptions should be handled by the Framework. They should return a generic error page and the necessary information should be logged but not displayed on a production environment.</li></ul><p>If we wanted to fix the example above it would rather look like;</p><pre>try {<br>    $remover-&gt;remove($group);</pre><pre>} catch (MyGroupUserException $exception) {<br>    // We know this exception is safe to be sent to the user.<br>    return new JsonResponse([&#39;message&#39; =&gt; $exception-&gt;getMessage()], 500);</pre><pre>} catch (MyGroupException $exception) {<br>    // This exception is not safe and should not happen. So we log and send a generic exception. <br>    $this-&gt;logger-&gt;error(&quot;There was an error while deleting the user group : {$exception-&gt;getMessage()}&quot;, [&#39;exception&#39; =&gt; $exception]);<br>    return new JsonResponse([&#39;message&#39; =&gt; &quot;The grouop coudln&#39;t be deleted&quot;], 500);<br>};</pre><pre>// All other exceptions will be handle by the framework. </pre><p>Of course, it’s is not always possible to control what we need to catch. Even some very popular and very good php libraries, throw generic exceptions instead of defining their own. In this case, we are obliged to catch <em>\Exception</em>. In this case, we need to :</p><ul><li>Always log the exception message. This will allow us to have the necessary information to debug the issue if needed.</li><li>Always show a generic error message to the user and not the exception message. This allows us to be sure no sensitive information can be leaked to the users.</li></ul><p>So if we needed to rewrite our example for this scenario it would rather look like this.</p><pre>try {<br>    $remover-&gt;remove($group);<br>} catch (\Exception $exception) {<br>    $this-&gt;logger-&gt;error(&quot;There was an error while deleting the user group : {$exception-&gt;getMessage()}&quot;, [&#39;exception&#39; =&gt; $exception]);<br>    return new JsonResponse([&#39;message&#39; =&gt; &quot;The group couldn&#39;t be deleted&quot;], 500);<br>};</pre><p>This has of course the downside of possibly generating a lot of unnecessary logs. We will talk about exploiting logs in another article.</p><p>For now, let’s rather talk about logging exception.</p><h3>Logging</h3><p>Logging properly and having your logs parsed and easily available is a subject on its own. One for which I will write another article. The really important part of a log is</p><ul><li>To be easily identifiable. A message such as “An error happened” is not an identifiable message. When you read the message you must be able to quickly determine where it might come from.</li><li>It needs to contain all the necessary data to debug. For example for an api, the url’s called and the parameters, as well as the response, should be logged.</li></ul><p>But let’s concentrate on logging an exception message.</p><ul><li>Prefix your log message before logging the exception message. This will make it easier to find the origin of the log and allow the log to have more meaning without having to look into the code.</li><li>Always add the exception to the context [‘exception’ =&gt; $exception]. This is the way PSR-3 says exceptions must be logged. <br><em>If an Exception object is passed in the context data, it MUST be in the ‘exception’ key. Logging exceptions is a common pattern and this allows implementors to extract a stack trace from the exception when the log backend supports it. Implementors MUST still verify that the ‘exception’ key is actually an Exception before using it as such, as it MAY contain anything.</em></li><li>Add additional information to the context such as the url of the page. If your code can be accessed from multiple pages this might make it easier to pinpoint the issue. Frameworks such as <a href="http://symfony.com/"><strong>Symfony </strong></a>does it automatically. But <a href="https://magento.com/"><strong>Magento </strong></a>for example won’t do it.</li></ul><h3><strong>To wrap it up.</strong></h3><p>There are basically 3 points when handling exceptions.</p><ul><li><strong>Know what you are catching.</strong></li><li><strong>Know what you are displaying to your user.</strong></li><li><strong>Know how to debug your exceptions when they are triggered.</strong></li></ul><p>This way you know that</p><ul><li>You are not leaking sensitive data to the user</li><li>You have user user-friendly messages displayed to your users</li><li>You have all the details for easy troubleshooting.</li></ul><h3>Another example</h3><p>I have taken an example from <strong>Akeneo</strong>; not because Akeneo is a bad product; it’s not the case, it actually works very well and it’s very well coded. Every piece of software will have small “errors” and I was surprised to see it in Akeneo.</p><p>I could have used a <strong>Magento</strong> example; <strong>Magento </strong>is full of such errors as well. One of my favorite examples is on the product pages controller.</p><pre>try {<br>    $page = $this-&gt;resultPageFactory-&gt;create();<br>    $this-&gt;viewHelper-&gt;prepareAndRender($page, $productId, $this, $params);<br>    return $page;<br>} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {<br>    return $this-&gt;noProductRedirect();<br>} catch (\Exception $e) {<br>    $this-&gt;_objectManager-&gt;get(\Psr\Log\LoggerInterface::class)-&gt;critical($e);<br>    $resultForward = $this-&gt;resultForwardFactory-&gt;create();<br>    $resultForward-&gt;forward(&#39;noroute&#39;);<br>    return $resultForward;<br>}</pre><p>At first, this looks good. What does it do this :</p><ul><li>If the entity does not exist then displays a 404.</li><li>If any other exception displays a 404 &amp; log the exception.</li></ul><p>So it looks like, it checks all 3 boxes; right?</p><ul><li>Know what you are catching. ✔️ We are catching NoSuchEntityException.</li><li>Know what you are displaying to your user. ✔️ A 404 page.</li><li>Know how to debug your exceptions ✔️ The error is logged.</li></ul><p>This one is actually tricky. If we pay attention, we actually don’t know what we are catching. The issue is all Magento entities throws <em>NoSuchEntityException. S</em>o if in any of the blocks on the product page try to load any other entity besides the product; we can end up with a 404. It could also be trying to load additional products for a cross-sell for example. In those cases, we have no information to debug why we got a 404.</p><p>Simply looking at the NoSuchEntityException’s message we can figure out that it’s not the product that can’t be loaded but for example a category. But we don’t have that information. It’s actually possible to get into such a scenario by just messing up contributions in the back office on a native Magento.</p><p>So reviewing this try-catch again with this knowledge; would rather say:</p><ul><li>Know what you are catching. ✖️ We are catching all <em>NoSuchEntityException</em>, we don’t know which entity was not found. The exception is too generic.</li><li>Know what you are displaying to your user. ✔️ A 404 page.</li><li>Know how to debug your exceptions ✖️ We have no logs about which type of entity was not found when catching the <em>NoSuchEntityException.</em></li></ul><h3>Conclusion</h3><p>I have spent more time then I would like to maintain old e-commerce websites. Handling your exceptions properly will make your code more maintainable for yourself, but also for all the other developers that will have to maintain the code at some point.</p><p>Even on projects I know I won’t maintain I am of the opinion that the top priorities are.</p><ul><li>Maintainability</li><li>Customer satisfaction / Cost</li></ul><p>Yes, maintainability is more important. Even if at first it might cost slightly more it will pay for itself in the long term. On quickly evolving websites with redesigns sometimes done every year, features added daily; the long term might be just in less than a year.</p><p>You must of course sometimes do compromises, but maintainability needs to be always kept in mind. And when you do a compromise you must know where you are possibly adding maintenance issues in order to add if possible documentation (this can just comment in the code in some cases).</p><p>We have seen how to handle exceptions, in the newt article I would like to talk a bit more on how to log and why logs are important.</p><p><a href="https://medium.com/@oliverde8/maintainability-logs-their-use-6ac3bb235e31">Maintainability — Logs &amp; Their use</a></p><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fffdd7a95a65" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/maintainability-handling-exceptions-properly-fffdd7a95a65">Maintainability — Handling exceptions properly.</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL — Pagination, You Are Probably Doing It Wrong]]></title>
            <link>https://medium.com/swlh/sql-pagination-you-are-probably-doing-it-wrong-d0f2719cc166?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d0f2719cc166</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[pagination]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Mon, 31 Aug 2020 07:14:50 GMT</pubDate>
            <atom:updated>2020-09-08T08:16:17.735Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL — Pagination, You Are Probably Doing It Wrong</h3><p>Am I crazy assuming you are doing pagination wrong? I mean how hard is pagination? it’s so simple how can you do it wrong?</p><p>Well, you might not be doing it wrong, but you are probably using <strong>LIMIT </strong>with <strong>OFFSET </strong>to do pagination. That has performance limitations you might not be aware of and you probably can do better or you need to secure some of your URL&#39;s.</p><p>You do not believe me? Well just check this graph down below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*9Xmmed5yDZ5Rs-rcXJ6VAw.jpeg" /></figure><p>This is done on a small dataset of a 100.000 lines with small 10 line pages. Using both Limit &amp; Offset for the first data series and the alternative method which I have called “optimized” which in reality is called <strong>keyset pagination</strong> or <strong>seek pagination</strong> where only a Limit is used. This was done on mysql 5.7.</p><p>What you can see here is by using the offset, that the first pages are relatively fast to open. The first 1200 pages which allows us to load at the end12K lines of data have all taken less then 2ms each. So if you are displaying a page to a user it’s still “okay”. But if the users also opens the last page of the site, then performance will drop. And the more pages you have the slower the last page will be to load.</p><p>So in this article we are going to clear out 3 questions:</p><ul><li>Do we need an order by when doing pagination? If so why</li><li>Why does using the offset slow downs the queries?</li><li>How can you get better performance across all pages without using the offset?</li></ul><p>Databases allows us to query a data with little knowledge of how they work; but some very simple queries can create performance issues. It’s important to understand the basics of how things work to be able to write better code. I do a lot of simplifications in this article to make it clear. I try and point out those simplifications as we go.</p><p>Before getting into the subject if you wish to see the difference in performance of both methods for yourself you can check this <a href="https://gist.github.com/oliverde8/3abcf5ffb3397454fefee1d9f3ff3b1e">gist </a>with the code I used. I didn’t post the code here as I don’t think it’s relevant (and it’s ugly).</p><h3>Not using an order by with limit &amp; offset</h3><p>You probably have seen, or even written queries such as</p><pre>SELECT * FROM test LIMIT 100, 10;</pre><p>At first glance this query doesn’t seems to be wrong; but it is.</p><p>First of all let’s see what might go wrong, then why it can go wrong.</p><p>Let’s use an example dataset with 10 rows, which contains only an ID.</p><pre>╔════╦════╦════╦════╦════╦════╦════╦════╦════╦════╗<br>║ 10 ║ 13 ║ 15 ║ 17 ║ 21 ║ 22 ║ 24 ║ 25 ║ 27 ║ 28 ║<br>╚════╩════╩════╩════╩════╩════╩════╩════╩════╩════╝</pre><p>Our first query <em>SELECT * FROM test LIMIT 0, 5; </em>should return the following data:</p><pre>╔════╦════╦════╦════╦════╗<br>║ 10 ║ 13 ║ 15 ║ 17 ║ 21 ║<br>╚════╩════╩════╩════╩════╝</pre><p>Our second data the following</p><pre>╔════╦════╦════╦════╦════╗<br>║ 22 ║ 24 ║ 25 ║ 27 ║ 28 ║<br>╚════╩════╩════╩════╩════╝</pre><p>The order here is not really important, what we really wish is to get all 10 elements. In 2 different pages so that are user can see all the numbers. And we think they can. Or can they?</p><p>In reality nothing prevents the second page to contain a row that was already loaded on the first. So we can have the following 2 pages:</p><pre>╔════╦════╦════╦════╦════╗<br>║ 10 ║ 13 ║ 15 ║ 17 ║ 21 ║<br>╚════╩════╩════╩════╩════╝<br>╔════╦════╦════╦════╦════╗<br>║ 22 ║ 24 ║ 10 ║ 27 ║ 28 ║<br>╚════╩════╩════╩════╩════╝</pre><p>And we have “10” displayed in both the first page and the second page and “25” never displayed.</p><p>Why can this happen? Well we have not said to to the sql server to order the data. This means the execution plan of the query may differ between 2 queries in which case the way it loads the data changes and therefore the order of the data might change. Adding the Order By you insure that your data is reliable.</p><p>This is a documented behavior and not a bug!</p><p>Do you loose something by adding the order by and securing the behavior? Well no.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/869/1*muo2V5okw1f3txf1JjbPhg.jpeg" /></figure><p>Pagination without and order by is not faster. Let’s see now why such queries are slow.</p><h3>Why does using offset slow down queries.</h3><p>To understand this we need first to understand how RDBMS will order the data. If our database schema is well done, we probably have an index on the field we are ordering by. We will assume in this article that our RDBMS uses B trees for those indexes. This is a simplification as the method used depends on the data type and even then they will rather use B tree variants. But for simplifications sake let’s assume that a simple B tree is used.</p><p>For our previous 10 rows the index would look as follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*LEYSiDt03RD5Eglo_ijwWg.png" /></figure><p>So when we execute our query to get first 5 results, the tree allow the 5 elements to be found immediately. So the following query will go through the the tree as follows:</p><p>SELECT * FROM my_table ORDER BY id LIMIT 5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*kv5vEmLLDfZ2POZBKfEGwg.png" /></figure><p>In this example just going through 5 leafs it was able to find the 5 smallest numbers. Let’s now load the second page and see what happens:</p><p>SELECT * FROM my_table ORDER BY id LIMIT 5 5</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*nUGCcK5HwfiFUP0d_aPGJA.png" /></figure><p>The index didn’t help, we still had to go through all the leafs in order to find the last 5. This is because there is no way for the RDBMS to know where it needs to start. So it has to find the first 5(in red) elements in order to load the next 5 elements.</p><h3>Optimizing the pagination</h3><p>How can we make our pagination work and fast in that case?</p><p>Simple, by profiting from the indexes.</p><p>The hypothesis we need to make here is that you are never going to open page 2 without opening page 1 before.</p><p>With this hypothesis we know that the last Id on page 1 was <strong>21 </strong>we can therefore ask the 5 first elements whose id is superior to 21.</p><pre>SELECT * FROM my_table WHERE id &gt; 21 ORDER BY id LIMIT 5</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/465/1*AfKec0mPQbH2Gebn4KL-Xw.png" /></figure><p>This way the index is utilized and we are checking very few unnecessary rows. This is called seek method or keyset pagination.</p><p>We can also see this by using the EXPLAIN command on both queries.</p><pre><em>EXPLAIN EXTENDED SELECT * FROM test LIMIT 5, 5\G<br>*************************** 1. row ***************************<br> id: 1<br> select_type: SIMPLE<br> table: test<br> partitions: NULL<br> type: ALL<br>possible_keys: NULL<br> key: NULL<br> key_len: NULL<br> ref: NULL<br> rows: 100104<br> filtered: 100.00<br> Extra: NULL</em></pre><p>In this example there are no keys being used. While with the keyset pagination the primary key will be used.</p><pre><em>EXPLAIN EXTENDED SELECT * FROM test WHERE col1 &gt; 21 LIMIT 5\G<br>*************************** 1. row ***************************<br> id: 1<br> select_type: SIMPLE<br> table: test<br> partitions: NULL<br> type: range<br>possible_keys: PRIMARY<br> key: PRIMARY<br> key_len: 4<br> ref: NULL<br> rows: 50052<br> filtered: 100.00<br> Extra: Using where<br>1 row in set, 2 warnings (0.00 sec)</em></pre><p><strong>Lets also note that some storage solutions such as Elasticsearch will even prevent you from querying a important offset for this same reason.</strong></p><h3>A few additional examples</h3><h4>Sorting per date</h4><p>If you are sorting per date there always is a risk that multiple rows have the same date. If those rows are just between 2 pages you are going to have an issue not loading some of those rows on neither page. To fix this you need to order on a second primary field.</p><pre>SELECT *<br>FROM my_table<br>WHERE (update_date = &#39;2017-12-21&#39; AND id &gt; 21) <br>    OR update_date &gt; &#39;2017-12-21&#39;<br>ORDER BY update_date,id LIMIT 5</pre><p>Basically we are fetching all the rows that has the same update date as the last row on the previous page, but whose id is different. And also rows that were updated later. This of course make the query more complicated.</p><h3>Conclusion</h3><p>You need to remember that; <strong>you must use an order by when doing pagination.</strong></p><p>There is an alternative to pagination, but it’s has limitations</p><ul><li>It won’t allow you to open a page without opening the previous page.</li><li>If you have multiple order by’s the query will become very complicated.</li></ul><p><strong>Therefore if you are displaying a pager with page numbers to your users; you are probably using the correct method but must limit the max page number.</strong></p><p>Limiting the number of usable pages is important. If you have let’s say 100 Million entries well a few users trying to open the last page can create more load on your servers then hundreds of users. So you should limit the number of usable pages and force the user to use filters &amp; additional sorting to find what he needs.</p><p>Or just have a next &amp; previous buttons using the the keyset pagination.</p><p><strong>If you are using pagination for batch processes and you are using the offset you are using the wrong method.</strong></p><p>Using a seek method/keyset pagination to load pages is very efficient; it will make your processes faster for no cost if you do it that way from the beginning. It will also secure the development for the future. If it works today with 10.000 rows it will work in 10 years when you have 10 Million rows.</p><p><strong>If you have an infinite scroll or a simpler page with just a next &amp; previous button you must also use the seek method/keyset pagination.</strong></p><p>Keyset pagination’s only limitations is jumping on a specific page. But that’s is in my opinion rarely needed. With proper UX/Design it can be avoided.</p><p>Keyset pagination has no size limit, you can query in a 100 million row table and if you have the right indexes all the pages will be fast. So in my opinion there is no reason not to use it instead of what we are more used of doing.</p><p>Sadly we are used to the classic offset pagination, and most frameworks allows us to do such pagination&#39;s; and actually even make it easier for us to use them.</p><p>We should avoid using offset as much as possible and only use it when absolutely necessary and putting proper protection in place.</p><h3>Additional content to read</h3><p>This also points to a very interesting website which makes a similar point. I would recommend you reading it: <a href="https://use-the-index-luke.com/no-offset">https://use-the-index-luke.com/</a></p><figure><a href="https://use-the-index-luke.com/no-offset"><img alt="" src="https://cdn-images-1.medium.com/max/180/0*_3R71KcaHgTbydcb.png" /></a></figure><p>Thank you for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d0f2719cc166" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/sql-pagination-you-are-probably-doing-it-wrong-d0f2719cc166">SQL — Pagination, You Are Probably Doing It Wrong</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magento 2 — A dead giant?]]></title>
            <link>https://medium.com/swlh/magento-2-a-dead-giant-22ed25020a6e?source=rss-8d7360674de4------2</link>
            <guid isPermaLink="false">https://medium.com/p/22ed25020a6e</guid>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[magento-2]]></category>
            <category><![CDATA[magento]]></category>
            <dc:creator><![CDATA[Oliver de Cramer]]></dc:creator>
            <pubDate>Mon, 24 Aug 2020 13:45:39 GMT</pubDate>
            <atom:updated>2020-09-08T09:30:16.870Z</atom:updated>
            <content:encoded><![CDATA[<h3>Magento 2 — A dead giant?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*UNniy172nifjPbx8yEsNCQ.jpeg" /></figure><p>First of all, this is my first article on medium. <strong>Hourayyy</strong>!</p><p>Until now I have been blogging on my personal website; <a href="https://oliver-decramer.com/">https://oliver-decramer.com</a> but without a lot of success.</p><p>I will be from now on, blogging here on what I consider “Important”. So some technical stuff or even maybe some fantasy. Time will tell exactly what I will publish.</p><p>To get into the subject; I am today, undecided whatever Magento2 is worse then Magento1.</p><blockquote><strong><em>Sacrilege</em></strong><em> you say?</em></blockquote><p>Well, let’s see, In on one hand we have <strong>Magento1</strong>:</p><ul><li>stable</li><li>relatively fast</li><li>easy to deploy;</li></ul><p>but</p><ul><li>it’s deprecated</li><li>not xsd for xml’s</li><li>no composer</li><li>….</li></ul><p>and then we have <strong>Magento2</strong> that is:</p><ul><li>maintained</li><li>has varnish support</li><li>composer for dependencies</li></ul><p>but</p><ul><li>is complex to deploy</li><li>has a slow BO</li><li>it’s slow without varnish</li><li>….</li></ul><p>I already <a href="https://oliver-decramer.com/blog/post/my-thoughts-on-magento2.html">wrote an article a few years back on what I thought about Magneto2</a>, and time passed by, new versions were released and; it didn’t improve.</p><p>When we installed a Magento1 for our clients we basically had to do 2 mandatory changes:</p><ul><li>Prevent database update/install scripts to run on a page load and create a script to execute these scripts. This allowed us to do deployments with nearly no down time with only a bit of organization on our side.</li><li>Add varnish support;</li></ul><p>We of course have some other scripts to debug and so; but nothing critical, deployments were simple. We could build the css as we wanted, and do the same for javascript.</p><p>On magento2 on the other hand; we have tried different processes and all of them are either not working or complex. So that’s going to be our first point of concern.</p><p>We will then talk about native bugs, and the fix process; as well as the version numbers.</p><p>And end it with “community” extensions.</p><h3>Let’s deploy Magento2</h3><p>I want to start by saying there is lot’s of different processes for deploying a code. But there is one proper process; and that is by deploying every time all the code; in an automated and reproducible way.</p><p>This has some advantages, that we will discuss on a later chapter.</p><p>To implement this you can use shell scripts; ansible whatever you like. There is then intermediate steps that are application dependent but those are the details.</p><h3>Building it on the servers</h3><p>For our first projects, after tinkering quite a bit with the <em>generate static</em> commands we decided to build everything on the server beside dependencies. So these are the steps we did</p><p>Locally or using CI</p><ul><li>Composer install</li></ul><p>On the server(s)</p><ul><li>Copy sources to the servers in /var/www/releases/&lt;my-release&gt;</li><li>Compile the di (setup:di:compile)</li><li>Deploy the static content (js &amp; css)(setup:static-content:deploy)</li><li>Put magento in maintenance</li><li>Change symlinks to have /var/www/current/ =&gt; /var/www/releases/&lt;my-release&gt;</li><li>Execute the database updated (setup:upgrade --keep-generated). The keep generated allows us to gain time and have less down time as we have already generated them before switching the symlink</li><li>Disable maintenance.</li></ul><p>With this procedure our only downtime is during the setup:upgrade so this at first seems to be a good solution. But it’s not without faults :</p><ul><li>The static deploy command is quite heavy on a websites with lots of locales. On some of our website with 30+ locales this can take over 30 minutes.</li><li>We are running quite heavy commands on all our servers, which ends up adding load to our servers and therefore increases page load times and therefore lowers the service quality.</li><li>The biggest issue is if something is wrong with our code, Magento in some cases will not be able to execute the compilation of the di or the static content. We only see this when we decide to deliver our code. If a CI ran those commands we could see it on the Merge request directly.</li></ul><p>So back to the drawing board. We know that a full deployment is the way to go. We need to find a way to make it work with Magento.</p><h3>Built it locally or in a CI</h3><p>This seems to be the most obvious solution, and usually works fine for other websites I work on(drupal; symfony). First let me explain what we did then why it didn’t work.</p><p>To do this, there is an extra step the developer needs to take locally. The magento setup:static-content:deploy needs for some reason the list of stores, if this list is not present then it will try and connect to the database, but as we are building the package in the CI we don’t have a database. To get around this every time they we add a store, we need to dump the config files:</p><p><em>app:config:dump</em></p><p>Then the CI/CD will</p><ul><li>composer install</li><li>Compile the di(setup:di:compile)</li><li>Deploy the static contents (setup:static-content:deploy)</li><li>Create an archive</li></ul><p>Now this archive can be deployed:</p><p>- Copy sources to the servers in /var/www/releases/&lt;my-release&gt;</p><p>- Put magento in maintenance</p><p>- Change symlinks to have /var/www/current/ =&gt; /var/www/releases/&lt;my-release&gt;</p><p>- Execute setup:upgrade — keep-generated</p><p>- Disable maintenance.</p><p>We have moved our static generation to the CI, this works as the config.php committed contains the list of all the stores.</p><p>This looks to bee good solution, for we can now deploy one package on all environments, and we are sure that if there is a bug on one and that we can’t reproduce on the other, it isn’t a source code issue. If there is an issue with our code preventing it from being built we can also see it before deploying.</p><p>It sounds to be the proper solution? Well it doesn&#39;t work. There is 2 important issue with having the list of stores in the config.php.</p><ul><li>First of all if the magento has never been installed instead of running the setup:upgrade we will run the install command, this will fail as it will try to load stores from the database that doesn&#39;t exist. Logic as the stores will only be created later on with one of our install scripts. But the stores being in the <em>config.php</em> file, magento thinks they already exist</li><li>Second issue is with the setup:upgrade, if you add a new store through a updata script, the store is in the config.php but not in the database which again cause an exception.</li><li>There is also issues if the store ids are different in the config file &amp; in the database. Not having all the stores in the config.php will also cause issues.</li></ul><p>These shouldn’t be much on issue as we don’t run installs and create new stores that often do we? Well that’s debatable. Ideally, we would like for anyone that starts to work on the project, to simply run a install script without the need to fetch a database. The install should create most if not all the different cases and allow anyone to work on the project.</p><p>We could also bee using a automated CD capable of creating from a new branch in git a test environment with a single click. But with this method we can’t do it simply. We need to download a database during the creation process. We need to keep the database up to date with the proper stores. It make’s it “complicated”</p><p>These 2 solutions works without adding any additional code to Magento. We ended up coming to the conclusion that even through I don’t think that having an additional module just to make magento deliverable isn’t a good solution we ended up doing it. On our current procedure we have 2 config files; and a script that automatically updates the second one. The main config.php is the one we use to run the website everywhere. It does not contain the stores.</p><p>We automatically generate a second config file with all the stores. The CI uses this file. It’s the best we could find; it’s simple for the developer they don’t need to manually think about editing the file. But it’s additional code we need to maintain.</p><blockquote>I had to choose the lesser evil. I would rather not choose if I had a choice. But I have to make it work so.</blockquote><h3>It’s natively bugged</h3><p>All applications have bugs, well most do. And something as complex as Magento 2 when first published is bound to have quite a lot of them.</p><p>That is expected, the issue is the way bugs are regarded.</p><ul><li>They are ignored as user failure or as not reproducible even through they can be quite critical.</li><li>Fixed in major versions; Forcing you to get new features you don’t need and possibly new bugs instead of just a fix.</li><li>Fixed and broken in different versions. This is the case with the ES 5+ search engine. In 2.3.3 pagination on product search &amp; category pages didn’t work. Only first page displayed products. With 2.3.4 the pagination works but the number of products is always incorrect.</li></ul><p>There is no clear view for us integrating magento; to know if a bug we found and that is affecting our e-commerce website will ever be fixed. I don’t think that’s normal. And I am not talking about small bugs, there are bugs affecting payment methods that go unresolved for years. Github issues are affected obscure internal magento ticket numbers which are quite useless.</p><p>Just check this graph of open issues</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YNKQjAbX27cdelJU7OMCpg.png" /><figcaption>Number of issues that are open at a given time (not number of new issues opened)</figcaption></figure><p>You can ignore the few abnormalities in this graph that I did using the github api’s. At some point end of 2017 they did a cleanup, during which many issues were closed without reason. But over 2000 open issues at date.</p><p>In average an issue takes 80 days to be closed. But there are issues that are more the 400 days old.</p><p>I agree that github issues are not always reflecting well the truth of what is going on. Most of those issues are indeed user issues or duplicates. I did compare this with a few other open source solutions and usually the number of open issues tends to stagnate at a certain point at much lower numbers. Magento is not doing that.</p><p>And don’t get me started with the Enterprise support. EE modules first of all are worse then the CE modules;</p><ul><li>Multiwarehouse not having proper elasticsearch support.</li><li>The B2B functionalities not having elasticsearch support again. (Fixed in 2.4)</li><li>Staging, and it’s nearly exponentially growing tables; I might actually do an article just on this. (2n-1 insert per version)</li><li>Page builder and it’s loosing your contributions. Don’t spent to long to edit the page, or don’t do to much without saving you never now when the javascript will crash.</li><li>…</li></ul><p>And if you do get in contact with the EE support; best case scenario after proving multiple ways the the bug is real; you are going to get on of those “.patch” files used by pirates in the 1660’s. That’s going to create conflicts at each update and will therefore become part of what you need to maintain. The official fix will be implemented in a very far future and break something else.</p><p>I would like to end this with a last word on the version numbers. When you upgrade any application from 2.3.4 to 2.3.5 you do not expect to be making huge changes. After all it’s bugfixes? Well not with magento; because magento does not respect semantic versioning. magento/magento2-base 2.3.4 will for example require magento/module-catalog 103.0.4. So this means you need to check the change logs for each version.</p><p>Magento 2.3.5, that’s the commercial version number, it has no technical sense at all. A “Minor” commercial version can be a major technical version. So it’s very developer friendly.</p><h3>Built without thought</h3><p>That’s really what I think of when I think of Magento, it’s an overly complex tool; that has lots of features but with none of them inspiring trust when you start to dig in to see how they work.</p><p>It’s been now 4 years since the release of Magento2 and each year new features find it’s way into the tool, no refinement no improvements is done to the core,<strong> layers are added ontop of layers</strong>. And more new bugs are introduced then fixed.</p><h3>Community modules</h3><p>I would like to finish this article with one last rant on the community modules.</p><blockquote>Why do we pay for this garbage?</blockquote><p>I won’t give names, but we just bought a bunch of modules for our customer and issues are pilling up,</p><ul><li>Some of them can’t be installed with composer, they have their own ClassLoader and needs to have files to be added to the lib folder(which we don’t commit). I don’t ask them to have their own package repository, just to give us a proper archive that we can use with composer artifacts. That’s split up’s the “editable” code from the vendor code sufficiently.</li><li>Outdated code, those modules that needs files to be added to the “lib” directory that they load them using their own Autoloader functions. Their code is pretty much the same as the M1 counterpart of the module. And the code is also probably used for woo-commerce and other php cms they support.</li></ul><p>I am not talking about bugs, just how things are done and how changing behavior and maintaining those module is complicated.There is no proper centralized repository to have information on updates. At each magento update we manually need to check for the updates.</p><p>The situation of the modules make it even harder to work with magento; Wordpress and Drupal have similar issues with modules breaking native features but at least heir installation procedure remains unchanged.</p><p>With Magento each module has it’s own way of getting installed and only few of them is installed out of the box with composer.</p><blockquote>There are some very good modules, usually open source modules are better then those you have to pay for.</blockquote><h3>Conclusions</h3><p>Magento used to be one of the only options to create an online website for a reasonable price. Today there are other open source alternatives such as Sylius; but there is also SAS alternatives such as Shopify.</p><p>Whatever solution is chosen it should be done logically. In some cases Magento 2 remains the most obvious choice even through all it’s downfalls, because it’s so feature rich. But on some project it is actually easier to develop features from scratch on Sylius for example, then handle the edge cases magento was never meant to handle.</p><p>I think Magento has less a place in today’s world; where e-commere websites don&#39;t just need to work; <strong>they need to be special</strong> while remaining easy to use and <strong>fast</strong>(magento2 is by no means fast). They also need to be stable and have little downtime.</p><p>Most of the clients I work with requires Magento and won’t even consider an alternative. But I think most of them would profit by using Sylius. Most of them don’t use most of Magento’s functionalities; and most of what is used has been customized to great extent and great labor. There are of-course exceptions; In some cases Magento is a perfect fit.</p><p>I do hope that Magento will be able to reinvent itself in the future, for today in my opinion the only reason it’s still alive is the good reputation of Magento 1 which causes companies to wish to upgrade to Magento 2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22ed25020a6e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/magento-2-a-dead-giant-22ed25020a6e">Magento 2 — A dead giant?</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>