<?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>Forem: Elie Hanna</title>
    <description>The latest articles on Forem by Elie Hanna (@eliehanna).</description>
    <link>https://forem.com/eliehanna</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%2F758843%2F1cba3885-2605-4139-9a2e-c2e9ed1d61fa.jpeg</url>
      <title>Forem: Elie Hanna</title>
      <link>https://forem.com/eliehanna</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/eliehanna"/>
    <language>en</language>
    <item>
      <title>How to Run PHPUnit in a WordPress Plugin on Windows Using LocalWP</title>
      <dc:creator>Elie Hanna</dc:creator>
      <pubDate>Thu, 28 Jul 2022 00:03:31 +0000</pubDate>
      <link>https://forem.com/eliehanna/how-to-run-phpunit-in-a-wordpress-plugin-on-windows-using-localwp-1414</link>
      <guid>https://forem.com/eliehanna/how-to-run-phpunit-in-a-wordpress-plugin-on-windows-using-localwp-1414</guid>
      <description>&lt;h4&gt;
  
  
  Table of Contents
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Requirements&lt;/li&gt;
&lt;li&gt;Select Git Bash as the default terminal&lt;/li&gt;
&lt;li&gt;Create a new WordPress plugin&lt;/li&gt;
&lt;li&gt;Installing WP tests&lt;/li&gt;
&lt;li&gt;Install PHPUnit&lt;/li&gt;
&lt;li&gt;Install PHPUnit Polyfills&lt;/li&gt;
&lt;li&gt;Change the Temp directory&lt;/li&gt;
&lt;li&gt;Running our first test&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Requirements
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://localwp.com/" rel="noopener noreferrer"&gt;Local&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Install &lt;a href="https://gitforwindows.org/" rel="noopener noreferrer"&gt;Git Bash for Windows&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Select Git Bash as the default terminal
&lt;/h4&gt;

&lt;p&gt;Once Local is installed, click on the hamburger menu on the top left then click on preferences.&lt;/p&gt;

&lt;p&gt;Under default apps, make sure that Git Bash is selected as the terminal app.&lt;/p&gt;

&lt;p&gt;If you can't select Git Bash, make sure that &lt;a href="https://gitforwindows.org/" rel="noopener noreferrer"&gt;Git Bash for Windows&lt;/a&gt; is installed in this location &lt;code&gt;C:\Program Files\Git&lt;/code&gt;&lt;br&gt;
&lt;a href="https://media.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%2Fkx70jrj0wtc2ez3mmpdq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fkx70jrj0wtc2ez3mmpdq.png" alt="LocalWP Settings"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Create a new WordPress plugin
&lt;/h4&gt;

&lt;p&gt;If you do not have a LocalWP site already, you can create one by clicking on the bottom left button in Local and go through the setup wizard, when you are done, you should be taken to your Local WP site dashboard that looks like this:&lt;br&gt;
&lt;a href="https://media.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%2Friq84nag3gscpfp8cxl2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Friq84nag3gscpfp8cxl2.png" alt="LocalWP New Site"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, open the site terminal by clicking on Open Site Shell &lt;br&gt;
&lt;a href="https://media.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%2Fhi06r8e0fazcz5wfryba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fhi06r8e0fazcz5wfryba.png" alt="LocalWP Open Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;wp scaffold plugin sample-plugin&lt;/code&gt; to create a plugin, this will also add the test files that we need.&lt;br&gt;
&lt;a href="https://media.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%2F33ubm68chbzu5238mn8u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F33ubm68chbzu5238mn8u.png" alt="wp scaffold Command Terminal"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note that if you wish to add the test files to an existing plugin you should run &lt;code&gt;wp scaffold plugin-tests sample-plugin&lt;/code&gt; instead.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The file structure of our generated plugin &lt;code&gt;sample-plugin&lt;/code&gt; should look like this:&lt;br&gt;
&lt;a href="https://media.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%2Fgs03bylvmxpbw9adiy0q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgs03bylvmxpbw9adiy0q.png" alt="New Plugin File Structure"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Installing WP tests
&lt;/h4&gt;

&lt;p&gt;Let's dive into our plugin directory with &lt;code&gt;cd wp-content/plugins/sample-plugin&lt;/code&gt; and run the &lt;code&gt;install-wp-tests.sh &amp;lt;db-name&amp;gt; &amp;lt;db-user&amp;gt; &amp;lt;db-pass&amp;gt; [db-host]&lt;/code&gt; like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;bin/install-wp-tests.sh wp_tests root root localhost 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;db-name&lt;/strong&gt;: this is our test database name that will be used to run tests, it could be anything as long as it's not our site's database name.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;db-user, db-pass, db-host&lt;/strong&gt;: are the values shown in your Local site Database tab:&lt;br&gt;
&lt;a href="https://media.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%2F0fw9ca3cvodrijj844op.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F0fw9ca3cvodrijj844op.png" alt="LocalWP Database Info"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this installation ran correctly, you shouldn't see any errors in the Git Bash terminal and you should see two new folders in your &lt;code&gt;%TEMP%&lt;/code&gt; directory &lt;code&gt;wordpress&lt;/code&gt; and &lt;code&gt;wordpress-tests-lib&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;More about the &lt;code&gt;%TEMP%&lt;/code&gt; directory below.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You should also see our created &lt;code&gt;wp-tests&lt;/code&gt; database if you run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysql
show databases;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.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%2Feq8wrjb4nm49q4n1hy03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Feq8wrjb4nm49q4n1hy03.png" alt="mysql show databases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Install PHPUnit
&lt;/h4&gt;

&lt;p&gt;We are going to install PHPUnit using Composer, LocalWP should come with Composer installed, to install PHPUnit run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require --dev phpunit/phpunit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Install PHPUnit Polyfills
&lt;/h4&gt;

&lt;p&gt;&lt;a href="https://github.com/Yoast/PHPUnit-Polyfills/" rel="noopener noreferrer"&gt;PHPUnit Polyfills&lt;/a&gt; are required to create PHPUnit tests in WordPress.&lt;/p&gt;

&lt;p&gt;To install them, Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;composer require --dev yoast/phpunit-polyfills
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Change the Temp directory
&lt;/h4&gt;

&lt;p&gt;If you were to run &lt;code&gt;vendor/bin/phpunit&lt;/code&gt; now, you would get some errors on the console missing files in directories. This is only an issue on Windows. To fix this open the &lt;code&gt;wordpress-tests-lib/wp-tests-config.php&lt;/code&gt; in your Temp directory and edit the constant &lt;code&gt;ABSPATH&lt;/code&gt; on line 4 and prepend your &lt;code&gt;%TEMP%&lt;/code&gt; directory.&lt;/p&gt;

&lt;p&gt;You can find the location of your Temp folder by typing &lt;code&gt;echo %TEMP%&lt;/code&gt; on the Windows Terminal:&lt;br&gt;
&lt;a href="https://media.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%2Fjcj67twnyroti6gymtex.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fjcj67twnyroti6gymtex.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My Temp folder path is &lt;code&gt;C:\Users\Elie\AppData\Local\Temp&lt;/code&gt; so my &lt;code&gt;ABSPATH&lt;/code&gt; looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;define( 'ABSPATH', 'C:\Users\Elie\AppData\Local\Temp/wordpress/' );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Running our first test
&lt;/h4&gt;

&lt;p&gt;Our plugin comes with a sample test in &lt;code&gt;tests/test-sample.php&lt;/code&gt;, to enable it open &lt;code&gt;phpunit.xml&lt;/code&gt; and comment out the line that has the &lt;code&gt;&amp;lt;exclude&amp;gt;&lt;/code&gt; tags:&lt;br&gt;
&lt;a href="https://media.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%2F8crncf70sudyh6woj77h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F8crncf70sudyh6woj77h.png" alt="phpunit.xml"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On your Git Bash terminal, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;vendor/bin/phpunit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;OK (1 test, 1 assertion)&lt;/code&gt; that means that the sample test was tested successfully!&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>phpunit</category>
      <category>localwp</category>
    </item>
    <item>
      <title>Setup a Local WordPress Development Environment with Docker that packs WP-CLI and Xdebug</title>
      <dc:creator>Elie Hanna</dc:creator>
      <pubDate>Sun, 21 Nov 2021 14:15:16 +0000</pubDate>
      <link>https://forem.com/eliehanna/setup-a-local-wordpress-development-environment-with-docker-that-packs-wp-cli-and-xdebug-2hcj</link>
      <guid>https://forem.com/eliehanna/setup-a-local-wordpress-development-environment-with-docker-that-packs-wp-cli-and-xdebug-2hcj</guid>
      <description>&lt;h2&gt;
  
  
  WordPress Docker Dev Environment
&lt;/h2&gt;

&lt;p&gt;This post aims to help WordPress developers quickly bootstrap a WordPress Docker development environment with WP-CLI, PHPMyAdmin and Xdebug.&lt;/p&gt;

&lt;h2&gt;
  
  
  Container Features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Auto install WordPress&lt;/li&gt;
&lt;li&gt;PHPMyAdmin&lt;/li&gt;
&lt;li&gt;Xdebug&lt;/li&gt;
&lt;li&gt;WP-CLI&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://docs.docker.com/desktop/"&gt;Docker Desktop&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://xdebug.org/docs/install"&gt;Xdebug&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clone this repo &lt;a href="https://github.com/eliehanna0/WordPress-Docker-Dev-Environment"&gt;https://github.com/eliehanna0/WordPress-Docker-Dev-Environment&lt;/a&gt; :
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/eliehanna0/WordPress-Docker-Dev-Environment.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Let's build and start our docker container, In the root folder of the project, run:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose up --build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might have to wait a minute or two the first time you run this for the &lt;code&gt;wordpress&lt;/code&gt; image to copy the necessary files.&lt;/p&gt;

&lt;p&gt;Meanwhile, the &lt;code&gt;wordpress-installer&lt;/code&gt; image waits until WordPress files are ready before automatically installing it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ncEGv8FA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142737457-a9a6787f-0934-4a31-a702-0ff7882d603f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ncEGv8FA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142737457-a9a6787f-0934-4a31-a702-0ff7882d603f.png" alt="image" width="880" height="85"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will know your installation is complete when you see this message:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LZ49SqdY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142737438-dcb24295-c7c4-4f43-8f0c-7b2853719431.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LZ49SqdY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142737438-dcb24295-c7c4-4f43-8f0c-7b2853719431.png" alt="image" width="880" height="91"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it, browse to &lt;a href="http://localhost/"&gt;http://localhost/&lt;/a&gt; to check your installed WordPress website, for PHPMyAdmin, go to &lt;a href="http://localhost:8080/"&gt;http://localhost:8080/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Using WP-CLI
&lt;/h2&gt;

&lt;p&gt;There are two ways to run &lt;a href="https://developer.wordpress.org/cli/commands/"&gt;WP-CLI commands&lt;/a&gt; in this Docker container.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;code&gt;docker-compose exec&lt;/code&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker-compose exec wordpress wp post list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2zgve8gx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738097-2d23adfb-55dc-47ec-89a3-5ee07be030b5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2zgve8gx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738097-2d23adfb-55dc-47ec-89a3-5ee07be030b5.png" alt="image" width="880" height="117"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Or my preferred way, SHH into the container like so:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker exec -it wordpress /bin/bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run whatever WP-CLI command for instance &lt;code&gt;wp post list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---EDxPNsx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738149-7ef6ba96-62f6-437c-b3ef-c8f9312fa39a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---EDxPNsx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738149-7ef6ba96-62f6-437c-b3ef-c8f9312fa39a.png" alt="image" width="880" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;by the way, use &lt;code&gt;exit&lt;/code&gt; to return to your terminal from bash&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging with PHPStorm
&lt;/h2&gt;

&lt;p&gt;Let us setup PHPStorm to listen to incoming Xdebug connections from our docker container.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup Xdebug in PHPStorm
&lt;/h3&gt;

&lt;p&gt;Go to &lt;code&gt;Settings &amp;gt; Languages &amp;amp; Frameworks &amp;gt; PHP &amp;gt; Debug&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We are using port &lt;code&gt;9003&lt;/code&gt; as configured in our &lt;code&gt;xdebug.ini&lt;/code&gt; &lt;a href="https://github.com/eliehanna0/WordPress-Docker-Dev-Environment/blob/main/conf/xdebug.ini"&gt;file&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IZS5aSka--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738823-abaa67a9-1d8a-4227-931a-e896cec26fae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IZS5aSka--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738823-abaa67a9-1d8a-4227-931a-e896cec26fae.png" alt="image" width="880" height="607"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Mapping The Server
&lt;/h4&gt;

&lt;p&gt;Navigate to &lt;code&gt;Settings &amp;gt; Languages &amp;amp; Frameworks &amp;gt; PHP &amp;gt; Servers&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a new server, I named mine &lt;code&gt;WP Docker&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Host is &lt;code&gt;localhost&lt;/code&gt; port &lt;code&gt;80&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Debugger is &lt;code&gt;Xdebug&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Make sure &lt;code&gt;Use path mappings....&lt;/code&gt; is checked ✔️&lt;/li&gt;
&lt;li&gt;Map the created &lt;code&gt;wordpress&lt;/code&gt; folder to &lt;code&gt;/var/www/html&lt;/code&gt; (this folder should have been created by the docker container)&lt;/li&gt;
&lt;li&gt;Click &lt;code&gt;OK&lt;/code&gt; to save your settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is how your settings should look:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oN7Vejlq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738745-57d64a80-3ac1-409b-87ae-e29be2c453d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oN7Vejlq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142738745-57d64a80-3ac1-409b-87ae-e29be2c453d6.png" alt="image" width="880" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Debug Configuration
&lt;/h4&gt;

&lt;p&gt;Go to &lt;code&gt;Run &amp;gt; Edit Configurations...&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add a new configuration and select &lt;code&gt;PHP Remote Debug&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Give it a name, mine is &lt;code&gt;WP Docker&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Select the server we just created &lt;code&gt;WP Docker&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Type an IDE key &lt;code&gt;PHPSTORM&lt;/code&gt; (any value will do since we are not filtering by IDE key in our xdebug.ini)&lt;/li&gt;
&lt;li&gt;Save your settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bu0mgWEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739245-53a8539b-f696-4c74-9709-9d83679e2349.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bu0mgWEV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739245-53a8539b-f696-4c74-9709-9d83679e2349.png" alt="image" width="880" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Let us test Xdebug!
&lt;/h4&gt;

&lt;p&gt;I am going to create a breakpoint in an already installed plugin &lt;code&gt;wordpress/wp-content/plugins/hello.php&lt;/code&gt; on line 54&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lT9iQyCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739301-ab63298d-f633-4d7c-a791-5743d0b24073.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lT9iQyCh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739301-ab63298d-f633-4d7c-a791-5743d0b24073.png" alt="image" width="880" height="381"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the top right toolbar of PHPStorm, select &lt;code&gt;WP Docker&lt;/code&gt; as our configuration and click on &lt;code&gt;Start listetning for PHP debug connections&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lGcx4mSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739343-e9a4e376-9652-4fdb-8cfd-cc252f19c49c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lGcx4mSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739343-e9a4e376-9652-4fdb-8cfd-cc252f19c49c.png" alt="image" width="682" height="87"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Navigate to &lt;code&gt;http://localhost/wp-admin/plugins.php&lt;/code&gt; and activate &lt;code&gt;Hello Dolly&lt;/code&gt; to see our debugger in action:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p9c-8-gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739552-3e8c5e6e-6110-42e0-b2b1-fd484b3f9689.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p9c-8-gr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739552-3e8c5e6e-6110-42e0-b2b1-fd484b3f9689.png" alt="image" width="880" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To stop listening to Xdebug connections click on the same button:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jpe9RCJA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739368-ff891393-7178-438d-9034-ca0916e75f03.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jpe9RCJA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://user-images.githubusercontent.com/76950619/142739368-ff891393-7178-438d-9034-ca0916e75f03.png" alt="image" width="699" height="86"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Roadmap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Integrate &lt;a href="https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/"&gt;Unit tests&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Add PHPCS&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Contribution
&lt;/h2&gt;

&lt;p&gt;Yes please! &lt;a href="https://github.com/eliehanna0/WordPress-Docker-Dev-Environment"&gt;https://github.com/eliehanna0/WordPress-Docker-Dev-Environment&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Thank You!
&lt;/h2&gt;

&lt;p&gt;Feel free to ask me any questions or offer any suggestions!&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
