<?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: AndersonPEM</title>
    <description>The latest articles on DEV Community by AndersonPEM (@andersonpem).</description>
    <link>https://dev.to/andersonpem</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%2F454946%2F2ad2446f-7e8f-4085-aa5c-f53226478a1b.png</url>
      <title>DEV Community: AndersonPEM</title>
      <link>https://dev.to/andersonpem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andersonpem"/>
    <language>en</language>
    <item>
      <title>Setting Up Multi-Architecture Docker Builds with QEMU</title>
      <dc:creator>AndersonPEM</dc:creator>
      <pubDate>Wed, 04 Dec 2024 16:14:27 +0000</pubDate>
      <link>https://dev.to/andersonpem/setting-up-multi-architecture-docker-builds-with-qemu-22mg</link>
      <guid>https://dev.to/andersonpem/setting-up-multi-architecture-docker-builds-with-qemu-22mg</guid>
      <description>&lt;h2&gt;
  
  
  Why Multi-Architecture Builds?
&lt;/h2&gt;

&lt;p&gt;With the rise of ARM-based systems like Apple Silicon Macs and AWS Graviton instances, building container images for multiple architectures has become essential. This guide explains how to set up your Ubuntu system for multi-architecture Docker builds.&lt;/p&gt;

&lt;h2&gt;
  
  
  System Requirements
&lt;/h2&gt;

&lt;p&gt;I'm assuming you're using a Debian or Debian derivate (Ubuntu, PopOS, Tuxedo OS, etc)&lt;/p&gt;

&lt;p&gt;First, install the necessary virtualization packages:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt &lt;span class="nb"&gt;install &lt;/span&gt;qemu-kvm qemu-system qemu-utils libvirt-daemon &lt;span class="se"&gt;\&lt;/span&gt;
  libvirt-clients bridge-utils ovmf cpu-checker

&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; kvm &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These packages provide:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QEMU: Hardware virtualization&lt;/li&gt;
&lt;li&gt;libvirt: API for virtualization&lt;/li&gt;
&lt;li&gt;bridge-utils: Network bridging tools&lt;/li&gt;
&lt;li&gt;OVMF: UEFI firmware for virtual machines&lt;/li&gt;
&lt;li&gt;cpu-checker: Verifies virtualization support&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setting Up Multi-Architecture Support
&lt;/h2&gt;

&lt;p&gt;Docker needs QEMU to emulate different CPU architectures. Configure this with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--privileged&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; tonistiigi/binfmt &lt;span class="nt"&gt;--install&lt;/span&gt; arm64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command installs the necessary binary format handlers for ARM64 architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating a Multi-Architecture Builder
&lt;/h2&gt;

&lt;p&gt;BuildKit, Docker's build system, needs a dedicated builder for multi-arch builds:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker buildx create &lt;span class="nt"&gt;--name&lt;/span&gt; multiarch &lt;span class="nt"&gt;--driver&lt;/span&gt; docker-container &lt;span class="nt"&gt;--bootstrap&lt;/span&gt;
docker buildx use multiarch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Building Multi-Architecture Images
&lt;/h2&gt;

&lt;p&gt;Build images for both AMD64 and ARM64 with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker buildx build &lt;span class="nt"&gt;--platform&lt;/span&gt; linux/amd64,linux/arm64 &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Test images on actual hardware when possible&lt;/li&gt;
&lt;li&gt;Use multi-stage builds to optimize image size&lt;/li&gt;
&lt;li&gt;Consider CI/CD pipeline integration for automated builds&lt;/li&gt;
&lt;li&gt;Tag architecture-specific images alongside multi-arch manifests&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Verification
&lt;/h2&gt;

&lt;p&gt;Verify your setup with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker buildx &lt;span class="nb"&gt;ls&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This should show your new builder with both platforms available.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>buildx</category>
      <category>qemu</category>
      <category>binfmt</category>
    </item>
    <item>
      <title>Symfony: The way of the bundle</title>
      <dc:creator>AndersonPEM</dc:creator>
      <pubDate>Wed, 28 Feb 2024 10:57:41 +0000</pubDate>
      <link>https://dev.to/andersonpem/symfony-the-way-of-the-bundle-2o22</link>
      <guid>https://dev.to/andersonpem/symfony-the-way-of-the-bundle-2o22</guid>
      <description>&lt;p&gt;In the realm of Symfony, where the architecture is as vast as the landscapes of code it governs, there exists a path for the wise: the way of the bundle. As a master guiding you, my apprentice, through the intricacies of Symfony, I shall unveil the secrets to abstracting your code into bundles, transforming your applications into a tapestry of reusable components, each a testament to the art of software craftsmanship.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Genesis of a Bundle&lt;/strong&gt;&lt;br&gt;
Imagine, young apprentice, a world where each feature of your application is not a tangled web of dependencies but a serene island of functionality. This is the essence of a bundle in Symfony. The journey begins with the identification of reusable features. Look closely at your codebase; what do you see? Perhaps a user management system, a payment processing library, or an API client whispering the tales of external services. These are your candidates for abstraction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Carving Out the Boundaries&lt;/strong&gt;&lt;br&gt;
With the features identified, the next step is to define the boundaries of each bundle. A bundle, much like the ancient temples, should be dedicated to a single deity, or in this case, a single feature. It should encompass all that is necessary for its function and nothing more. This is the principle of cohesion—a bundle should be self-contained, a microcosm of functionality.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Structure of Sanctity&lt;/strong&gt;&lt;br&gt;
As you craft your bundle, adhere to the sacred structure recommended by Symfony:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Entities: The heart of your bundle, where the essence of your feature is modeled.
Repositories: The oracles, through which the knowledge of your entities is queried.&lt;/li&gt;
&lt;li&gt;Services: The priests, interpreting the divine logic of your domain.&lt;/li&gt;
&lt;li&gt;Controllers: The messengers, conveying requests and responses to and from the mortal realm.
Configuration: The scriptures, allowing the mortals to customize the divine will.&lt;/li&gt;
&lt;li&gt;Tests: The trials, ensuring the deity's will is pure and uncorrupted.&lt;/li&gt;
&lt;li&gt;Flexibility and Configurability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A bundle must be as the willow, flexible in the wind. Provide means for the mortals to configure it, to bend its functionality to their will without breaking it. Use configuration files and expose extension points. Let others extend the reach of your bundle through events and dependency injection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Chronicles of Documentation&lt;/strong&gt;&lt;br&gt;
Documentation is the map to the treasure, the guide through the labyrinth. Without it, the mortals are lost. Detail the installation, provide examples of usage, enumerate configuration options, and describe how to extend the bundle. Your words will light the path for others to follow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Art of Decoupling&lt;/strong&gt;&lt;br&gt;
A bundle should stand alone, a citadel on a hill. It should not depend on the villages below for its survival. Use interfaces and dependency injection to manage dependencies, ensuring that your bundle can be lifted and placed into another project without upheaval.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Ritual of Distribution&lt;/strong&gt;&lt;br&gt;
When your bundle is ready, release it into the wild. Use version control and consider publishing it on Packagist. Embrace semantic versioning to communicate your changes to the world. Let the continuous integration spirits test your bundle, ensuring its purity remains untainted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An Example for the Ages&lt;/strong&gt;&lt;br&gt;
Let us consider some examples:&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 1: Logging Bundle
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A bundle dedicated to logging activities across your Symfony projects. It can offer configurable log formats, handlers, and processors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entity&lt;/strong&gt;: Log entries that can be stored in a database.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Services&lt;/strong&gt;: A logging service that abstracts the logic of writing logs, potentially supporting different levels of logging (info, warning, error) and different storage mechanisms (file, database).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration&lt;/strong&gt;: Options for setting the log level, log format, and the choice of handler (e.g., Monolog).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt;: Unit and integration tests to ensure the logging mechanism works as expected under various conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: Through extension points, allow other bundles or applications to define custom log processors or handlers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 2: E-commerce Bundle
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A bundle to add e-commerce capabilities, including product management, cart operations, and order processing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Entities&lt;/strong&gt;: Products, Carts, Orders, and related models.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repositories&lt;/strong&gt;: To manage data retrieval and manipulation for the e-commerce entities.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Services&lt;/strong&gt;: Business logic for cart operations, order processing, payment integration, and inventory management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Controllers&lt;/strong&gt;: Endpoints for product listing, cart management, checkout process, and order tracking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration&lt;/strong&gt;: Customizable settings for payment gateways, tax calculation, shipping options, and currency formats.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt;: Comprehensive tests to ensure reliability and security of the e-commerce transactions and data integrity.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: Offer hooks and events for integration with payment gateways, shipping services, and external inventory systems.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 3: API Bundle
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A bundle to facilitate the creation and management of RESTful APIs, providing tools for request validation, response formatting, and API versioning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Services&lt;/strong&gt;: API response builder, request validator, and version management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Controllers&lt;/strong&gt;: Base controller with common functionalities like response formatting and error handling.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration&lt;/strong&gt;: Settings for API versioning, default response formats, and security policies (e.g., API keys, OAuth).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt;: Tests to ensure API endpoints adhere to the specified request and response formats and handle errors gracefully.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: Configuration options for enabling CORS, defining API rate limits, and selecting serialization groups for different API versions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example 4: Notification Bundle
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Purpose&lt;/strong&gt;: A bundle to handle notifications across various channels (email, SMS, push notifications) with a unified interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Components&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Services&lt;/strong&gt;: Notification sender service that abstracts the complexity of sending notifications through different channels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Configuration&lt;/strong&gt;: Options to configure different notification channels, templates, and default settings for each type of notification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tests&lt;/strong&gt;: Ensure that notifications are sent correctly and fallback mechanisms work in case of failures with any channel.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Flexibility&lt;/strong&gt;: Allow developers to extend the bundle by adding custom notification channels and integrating with third-party services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The way of the bundle is a path of wisdom, of foresight. It is the understanding that what we create today should stand the test of time, should be a beacon for those who come after us. In the vast landscapes of Symfony, let your code be a testament to the art of reuse, a series of bundles, each a masterpiece of functionality. This is the way of the bundle, the path to enlightenment in the realm of Symfony. Walk it with pride, young apprentice, and let your code illuminate the darkness.&lt;/p&gt;

</description>
      <category>symfony</category>
      <category>bundles</category>
      <category>composer</category>
    </item>
    <item>
      <title>Laravel Sail &amp; XDebug</title>
      <dc:creator>AndersonPEM</dc:creator>
      <pubDate>Wed, 26 Apr 2023 11:01:44 +0000</pubDate>
      <link>https://dev.to/andersonpem/laravel-sail-xdebug-214o</link>
      <guid>https://dev.to/andersonpem/laravel-sail-xdebug-214o</guid>
      <description>&lt;h2&gt;
  
  
  Sailing on turbulent waters
&lt;/h2&gt;

&lt;p&gt;Laravel Sail is a project focused on giving developers a &lt;em&gt;dockerized&lt;/em&gt; environment without hassling with the internals of Docker.&lt;/p&gt;

&lt;p&gt;I've been in contact with this project for some days and found it incredibly frustrating making XDebug work properly on PHPStorm.&lt;/p&gt;

&lt;p&gt;Me being the Docker nerd I am, I started to mess with Sail's Docker image to make it work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why?
&lt;/h2&gt;

&lt;p&gt;There are 2 kinds of developers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The ones who use dd or console.log() to debug and&lt;/li&gt;
&lt;li&gt;The ones who use debugging tools.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In my years of experience, the latter usually makes debugging faster and comprehensible. You can walk through the code line by line, inspect memory, check if conditionals are working, it has saved me days of headaches.&lt;/p&gt;

&lt;h2&gt;
  
  
  Okay, what's wrong with my Sail?
&lt;/h2&gt;

&lt;p&gt;It seems like Sail's default config does not ship (pun intended) proper XDebug configuration for some environments (in my case, the env variables did not work at all). So, if you're not able to make it work the default way, come with me. Let's dew it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting your hands dirty
&lt;/h2&gt;

&lt;p&gt;Create a file called 20-xdebug.ini somewhere in your project. You can create a folder called docker, for example and add it to your .gitignore, so you don't commit config to your repository.&lt;/p&gt;

&lt;p&gt;We are going to add a path mapping to the application container in docker-compose.yml&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyoclqfvd078ekjsd4ca.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyoclqfvd078ekjsd4ca.png" alt=" " width="754" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Considering you have added the file 20-xdebug.ini to a folder called Docker, add the following volume to your container:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;- './docker/20-xdebug.ini:/etc/php/8.1/cli/conf.d/20-xdebug.ini'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;(I assumed you're using PHP 8.1. If not, change the path version accordingly)&lt;/p&gt;

&lt;p&gt;This command will map the file on your computer to PHP's XDebug config.&lt;/p&gt;

&lt;p&gt;The file contents is as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;zend_extension=xdebug.so
[xdebug]
xdebug.start_with_request=yes
xdebug.discover_client_host=true
xdebug.max_nesting_level=256
xdebug.remote_handler=dbgp
xdebug.client_port=9003
xdebug.idekey=Docker
xdebug.mode=develop,debug
xdebug.client_host=host.docker.internal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file sets the PHP to some default debug behaviors, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set the port of XDebug to 9003 (9000 might be busy with PHP-FPM or Node applications)&lt;/li&gt;
&lt;li&gt;Starts debugging with request&lt;/li&gt;
&lt;li&gt;Sets an IDE key, which is useful for PHPStorm's debug configuration&lt;/li&gt;
&lt;li&gt;Sets the client host to the gateway (your computer)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Among others :)&lt;/p&gt;

&lt;p&gt;Now let's configure PHPStorm.&lt;/p&gt;

&lt;p&gt;In the upper right corner, click on the debug options. Then on 'Edit configurations'&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7bqsxnjbxymdpmsaqtsx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7bqsxnjbxymdpmsaqtsx.png" alt=" " width="261" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You'll be presented with a dialog. Click on add new configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75xn555x8in9k8fh423l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F75xn555x8in9k8fh423l.png" alt=" " width="727" height="154"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Choose the option PHP Remote debug&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkf85rfqsdbev6qoh2n3x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkf85rfqsdbev6qoh2n3x.png" alt=" " width="243" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give your debug config a name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6sg8cnc712ynt7fme9u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb6sg8cnc712ynt7fme9u.png" alt=" " width="708" height="128"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on 'Filter debug connection by IDE key' and click on the triple dot button of the servers option to add a new server.&lt;/p&gt;

&lt;p&gt;Name your server Docker. To the host, add either 0.0.0.0 or localhost&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0obi65eq3vjxqty1lgb3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0obi65eq3vjxqty1lgb3.png" alt=" " width="800" height="352"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure to map your project's root directory to the container's /var/www/html.&lt;/p&gt;

&lt;p&gt;Click OK. Then, on the previous dialog select the Docker server. Also, add the Docker IDE session key.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7n2v30u88cgkde7fdsg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo7n2v30u88cgkde7fdsg.png" alt=" " width="800" height="610"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click OK and you're likely set to go.&lt;/p&gt;

&lt;p&gt;Select your Docker configuration for debug, and mind this icon:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjuted3u4naxagxbpbqlv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjuted3u4naxagxbpbqlv.png" alt=" " width="358" height="90"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it's all green, it's listening to debug connections. If it's red, it's not listening. In this case, no breakpoints will be triggered.&lt;/p&gt;

&lt;p&gt;Click on it to make it green.&lt;/p&gt;

&lt;p&gt;You should be able to breakpoint through the project when you go sail up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some caveats
&lt;/h2&gt;

&lt;p&gt;There's a default config of PHPStorm that really bothers me. For example, when you start a container, the routines executed firstly trigger the debugger without me asking for it.&lt;/p&gt;

&lt;p&gt;To avoid this, go to PHPStorm's settings, then go in PHP&amp;gt;Debug.&lt;/p&gt;

&lt;p&gt;Set it as following:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4m0tnd5od41oppamd1p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fr4m0tnd5od41oppamd1p.png" alt=" " width="728" height="718"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will avoid accidental triggering of the debugger, for example, when the PHP server is starting. If it's not allowed to start, the process will hang, and you won't be able to run pages.&lt;/p&gt;

&lt;p&gt;If you suspect there might be path mapping issues, tick back the 'Force break at first line if no path mapping is specified' option to check if you need to map something else. Then, untick it, because it can get pretty annoying.&lt;/p&gt;

&lt;p&gt;That's it for today, kids.&lt;/p&gt;

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