<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Erik D'Ercole</title>
    <description>The latest articles on DEV Community by Erik D'Ercole (@eleftrik).</description>
    <link>https://dev.to/eleftrik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F204320%2F580dcca1-d6f6-41cc-a791-872069c45e05.jpeg</url>
      <title>DEV Community: Erik D'Ercole</title>
      <link>https://dev.to/eleftrik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/eleftrik"/>
    <language>en</language>
    <item>
      <title>Laradhoc - Dockerize your Laravel app. Be a happy dev</title>
      <dc:creator>Erik D'Ercole</dc:creator>
      <pubDate>Tue, 31 Mar 2020 20:48:24 +0000</pubDate>
      <link>https://dev.to/eleftrik/laradhoc-dockerize-your-laravel-app-be-a-happy-dev-4a1p</link>
      <guid>https://dev.to/eleftrik/laradhoc-dockerize-your-laravel-app-be-a-happy-dev-4a1p</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KFZ4OwbM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/6959298/78071513-f83c9100-739d-11ea-9ff5-c63c1843bb3b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KFZ4OwbM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/6959298/78071513-f83c9100-739d-11ea-9ff5-c63c1843bb3b.png" alt="Laradhoc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;⚠️ This is my first post &lt;em&gt;ever&lt;/em&gt;. Any suggestion will be highly appreciated ♥️&lt;/p&gt;

&lt;h1&gt;
  
  
  tl;dr
&lt;/h1&gt;

&lt;p&gt;&lt;a href="https://github.com/eleftrik/laradhoc"&gt;Laradhoc&lt;/a&gt;, hosted on &lt;strong&gt;GitHub&lt;/strong&gt;, is my basic &lt;strong&gt;Docker&lt;/strong&gt;-based development environment for running &lt;strong&gt;Laravel&lt;/strong&gt; applications.&lt;/p&gt;

&lt;p&gt;Check it out and feel free to try it, do a fork, open an issue or a pull-request. I'll be happy to hear your suggestions, fix my mistakes and learn something new 😄&lt;/p&gt;

&lt;h1&gt;
  
  
  Before Laravel
&lt;/h1&gt;

&lt;p&gt;I'm a &lt;strong&gt;Laravel&lt;/strong&gt; developer and enthusiast since version 4.&lt;br&gt;
I love it. &lt;br&gt;
Before Laravel, there was &lt;strong&gt;CodeIgniter&lt;/strong&gt;... And even before there was pure PHP ⚠️. If I go back up to the origins (speaking of PHP development), I remember a lot of procedural code, big tons of spaghetti 🍝, manual &lt;code&gt;include&lt;/code&gt;, countless unaware vulnerabilities, dirty mixtures of PHP / HTML and Javascript, etc. 🙈&lt;br&gt;
No OOP, no Composer, no PSR-2, no frameworks, no SOLID, design patterns, unit tests. 🤦🏻‍♂️&lt;br&gt;
Dependency injection, service container, zero-downtime deploy, caching, CLI tools, queue workers... What? 🤨&lt;br&gt;
A looooot has been changing during these years and it's still changing, with increasing speed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Y A W N&lt;/em&gt; 🥱 You're talking about code, not development environments&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You're right. Let's go back in topic.&lt;br&gt;
Basically, during my PHP developer life, I went through these stages. I try to summarize them.&lt;/p&gt;

&lt;h1&gt;
  
  
  A quick (?) history of (my) dev environments
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1 - Manual / WAMP
&lt;/h3&gt;

&lt;p&gt;Install everything on your host, literally "by hand".&lt;br&gt;
I used to work on a Windows pc and I manually downloaded a zip file with the PHP version I needed. Same for Apache. No CLI. Just a Windows service and a bunch of config file to edit.&lt;/p&gt;

&lt;p&gt;Need to update? Repeat the same steps. And hope nothing is gonna break 😵&lt;/p&gt;

&lt;p&gt;To be honest, the technology stack wasn't still changing so fast. So it wasn't such a big deal.&lt;/p&gt;

&lt;p&gt;Oh, of course there were those "packaged solutions" like WAMP, but honestly I wasn't a big fan. They could make your life a bit easier, but I preferred to understand a bit deeply the "building blocks". &lt;/p&gt;

&lt;h3&gt;
  
  
  2 - Vagrant / Homestead
&lt;/h3&gt;

&lt;p&gt;When I discovered Vagrant, Homestead and these &lt;em&gt;VM-based&lt;/em&gt; solutions, I remember it was like "WOW 😱 Different configurations for different applications? This is magic!".&lt;br&gt;
Another advantage: the ability to share, in the same dev team, the same virtual machine with its settings, doesn't matter if your host is Windows or MacOS based (&lt;em&gt;even if I remember it wasn't exactly always like this...&lt;/em&gt;).&lt;br&gt;
But these VMs were pretty huge, heavy and not-so-performant.&lt;/p&gt;

&lt;h3&gt;
  
  
  3 - Docker!
&lt;/h3&gt;

&lt;p&gt;And then there was Docker!&lt;br&gt;
Which is the current solution my team and I use for local development.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Docker?
&lt;/h1&gt;

&lt;p&gt;In my opinion, &lt;strong&gt;Docker&lt;/strong&gt; is one of those &lt;strong&gt;life-changing inventions&lt;/strong&gt;, such as &lt;strong&gt;GIT&lt;/strong&gt;, for example. It's pure genius 🎓.&lt;/p&gt;

&lt;p&gt;Don't want to explain here what Docker is, which great benefits it brings and why you should adopt it as soon as you can: there are &lt;strong&gt;tons&lt;/strong&gt; of articles which explain all these concepts, much better than I would do.&lt;/p&gt;

&lt;p&gt;Let me write only a few words: along with your application code (e.g. your private GIT repository), you also provide (via one or a handful of configuration files) the exact &lt;strong&gt;infrastructure&lt;/strong&gt; to run it: which &lt;strong&gt;services&lt;/strong&gt; and which &lt;strong&gt;versions&lt;/strong&gt;, how are they &lt;strong&gt;configured&lt;/strong&gt; and how they &lt;strong&gt;interact&lt;/strong&gt; between theirselves. It doesn't matter if you're using &lt;strong&gt;Windows&lt;/strong&gt;, &lt;strong&gt;Linux&lt;/strong&gt; or &lt;strong&gt;MacOS&lt;/strong&gt;. It's almost like &lt;em&gt;download this, press play, wait... And you're ready to code&lt;/em&gt; 🤓 &lt;/p&gt;

&lt;p&gt;The latter aspect is very import for me: I mainly develop on &lt;strong&gt;MacOS&lt;/strong&gt; workstations, but also on &lt;strong&gt;Windows 10&lt;/strong&gt; (with &lt;strong&gt;WSL&lt;/strong&gt;). So, it's very important for me to have a solutions which works &lt;strong&gt;everywhere&lt;/strong&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  How I approached Docker?
&lt;/h1&gt;

&lt;p&gt;When I heard about it, at first, I was a bit &lt;em&gt;scared&lt;/em&gt; 😓.&lt;br&gt;
It was like "it sounds great, but not so easy to learn... And it's another topic to learn, I've no time, Homestead works pretty well, bla bla bla". You know... &lt;code&gt;excuses&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;During my spare time, I started to read some article, watch some video and try to become acquainted with Docker terminology: images, containers, docker-compose, volumes, etc.&lt;br&gt;
But still I couldn't find a concrete reason to revise my workflow (&lt;code&gt;laziness&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;Then I started to use some &lt;strong&gt;Docker-based solutions / products&lt;/strong&gt; (let me call them Docker &lt;em&gt;supersets&lt;/em&gt;, &lt;em&gt;wrappers&lt;/em&gt;), which are &lt;strong&gt;quite easy to setup&lt;/strong&gt; and they completely (or almost) hide the underlying complexity (even if it's not so complex) 🚀.&lt;/p&gt;

&lt;p&gt;Just a few names:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://localwp.com/"&gt;Local by Flywheel&lt;/a&gt;
Need a quick way to run your &lt;strong&gt;WordPress&lt;/strong&gt; blog / application locally? This is a pretty, easy and straightforward solution &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://laradock.io"&gt;Laradock&lt;/a&gt;
A full and highly configurable solution for running &lt;strong&gt;Laravel&lt;/strong&gt; applications. But I soon found it to be pretty &lt;em&gt;intricate&lt;/em&gt; to setup&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://lando.dev"&gt;Lando&lt;/a&gt;
Until now, my &lt;em&gt;favorite Docker-based tool&lt;/em&gt;. You can you use it for &lt;strong&gt;Laravel&lt;/strong&gt;, &lt;strong&gt;WordPress&lt;/strong&gt; and many other applications. It requires only to define your stack (services, versions, configurations, etc.) within a &lt;code&gt;.yaml&lt;/code&gt; file, which you're going to commit in your repository. Et voilà! You definitely want to try it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Docker the &lt;em&gt;manual way&lt;/em&gt;, then Laradhoc
&lt;/h1&gt;

&lt;p&gt;What's wrong with the aforementioned products? Nothing!&lt;br&gt;
Ok, almost nothing 😅&lt;br&gt;
For example &lt;strong&gt;Lando&lt;/strong&gt;, which I keep on loving, it's not so fast in bootstrapping.&lt;br&gt;
Another downside is this: Lando requires a specific locked version of Docker. I remember that one time, after upgrading Docker (via automatic updates), Lando suddenly broke and I couldn't understand what was going on. After many tests and some searching, a GitHub issue came up so I finally understood I had to downgrade Docker. &lt;br&gt;
Same for &lt;strong&gt;Laradock&lt;/strong&gt;: these products are meant to work out the of box, but soon or later you'll experience a configuration which is working on MacOS but not on Windows (or viceversa), or a particular setup or combination of services / versions which is leading to unexpected behaviours. &lt;/p&gt;

&lt;p&gt;But this isn't the &lt;strong&gt;main reason&lt;/strong&gt;. We all know the perfect software doesn't exist (especially the one you've written and you're so proud of 😝) and every product soon or later is going to meet some problem, bug, unexpected behaviour and so no.&lt;/p&gt;

&lt;p&gt;So, what's the matter? 🤷🏻‍♂️&lt;/p&gt;

&lt;p&gt;After starting to use these products, I became &lt;strong&gt;curious&lt;/strong&gt; 👀 and wanted to learn more about Docker. I wanted to experiment by myself, to understand and put into practice all the concepts I've read about in the previous months.&lt;br&gt;
I read more articles, took a look at several open source repositories, then I tried to sum up everything in a project I could use in my everyday developer life.&lt;br&gt;
After some initial doubt, I said to myself:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Ok, let's try to be "shameless". I want to put my project on GitHub, even if I have little or no experience with open source. What can be wrong? At worst, someone will say "this is wrong!" or "this is how it's done": in both cases, I will learn something.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Laradhoc
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;Laravel &lt;em&gt;ad hoc&lt;/em&gt; environment&lt;/strong&gt;. I just wanted something tailored for my needs.&lt;br&gt;
Of course it's not as complete as, for example, Lando.&lt;br&gt;
But it's &lt;strong&gt;fast&lt;/strong&gt; in bootstrapping (after downloading all the images and after the first build, of course) and &lt;strong&gt;enough complete&lt;/strong&gt; to run my projects.&lt;br&gt;
I didn't want to be too &lt;em&gt;strict&lt;/em&gt;, so I included even some service I usually don't need (e.g. phpMyAdmin - I prefer to use a SQL client).&lt;/p&gt;

&lt;p&gt;I tried to explain everything in the &lt;a href="https://github.com/eleftrik/laradhoc/blob/master/README.md"&gt;README.md&lt;/a&gt;; anyway, a very quick overview.&lt;/p&gt;

&lt;h4&gt;
  
  
  Features
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Nginx&lt;/li&gt;
&lt;li&gt;PHP 7.4 with OPCache&lt;/li&gt;
&lt;li&gt;MySql 8&lt;/li&gt;
&lt;li&gt;phpMyAdmin&lt;/li&gt;
&lt;li&gt;Mailhog&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;Custom domain name (es. &lt;a href="http://laradhoc.test"&gt;http://laradhoc.test&lt;/a&gt; or &lt;a href="https://laradhoc.test"&gt;https://laradhoc.test&lt;/a&gt;)
HTTP or HTTPS (with self-signed SSL certificate)
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It comes with some useful bash &lt;strong&gt;scripts&lt;/strong&gt; to start/stop the containers, run &lt;code&gt;composer&lt;/code&gt;, &lt;code&gt;php artisan&lt;/code&gt; and all the main Laravel-related &lt;em&gt;stuff&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;Give it a try!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/eleftrik/laradhoc"&gt;https://github.com/eleftrik/laradhoc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I already said, I would be happy to know what you think about!&lt;br&gt;
Feel free to ask for some new feature or to suggest some better implementation. &lt;/p&gt;

&lt;p&gt;Thanks for reading and good coding! 🤓&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>docker</category>
      <category>php</category>
      <category>github</category>
    </item>
  </channel>
</rss>
