<?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: Lucas Carvalho</title>
    <description>The latest articles on DEV Community by Lucas Carvalho (@lucascarvalhopl).</description>
    <link>https://dev.to/lucascarvalhopl</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%2F1298837%2Ff0b0be2e-451e-473f-8042-25a7711908e9.jpeg</url>
      <title>DEV Community: Lucas Carvalho</title>
      <link>https://dev.to/lucascarvalhopl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucascarvalhopl"/>
    <language>en</language>
    <item>
      <title>The PHP Orkestra Framework</title>
      <dc:creator>Lucas Carvalho</dc:creator>
      <pubDate>Mon, 06 May 2024 02:05:53 +0000</pubDate>
      <link>https://dev.to/lucascarvalhopl/the-php-orkestra-framework-2laj</link>
      <guid>https://dev.to/lucascarvalhopl/the-php-orkestra-framework-2laj</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Some months ago I started a side project aiming for study and personal use to create a new PHP framework capable to seamless integrate with wordpress as a plugin or to work fully autonomous. Based on &lt;a href="https://www.php-fig.org/psr/"&gt;PSR&lt;/a&gt; and best practicess, following &lt;a href="https://en.wikipedia.org/wiki/SOLID"&gt;SOLID&lt;/a&gt; and &lt;a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself"&gt;DRY&lt;/a&gt; principles at the best.&lt;/p&gt;

&lt;p&gt;This last week I finaly ended the first version of the &lt;a href="https://packagist.org/packages/luccpl/orkestra"&gt;Orkestra framework&lt;/a&gt; core, with all critical components tested and working as expected.&lt;/p&gt;

&lt;p&gt;As Matt Mullenweg said before, "code is poetry" and the Orkestra framework whas build to allow developers to create art expressed in if's and classes, leveraging the best in PHP ecossistem to allow you to conduct each small part of your software to work seamsly with other with nice and elegant structure.&lt;/p&gt;

&lt;p&gt;The goal of Orkestra is to be high extensible, simple to work with and integrate with different environments as Wordpress (the reason that this first release does not includes a &lt;a href="https://en.wikipedia.org/wiki/Object%E2%80%93relational_mapping"&gt;database ORM&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why not just use Laravel?
&lt;/h2&gt;

&lt;p&gt;Currently &lt;a href="https://laravel.com/"&gt;Laravel&lt;/a&gt; is the "go to" for new PHP applications to mostly developers today, if not, plain PHP, &lt;a href="https://www.slimframework.com/"&gt;Slim&lt;/a&gt;, &lt;a href="https://symfony.com/"&gt;Symfony&lt;/a&gt; and other frameworks does the job, but for Wordpress, custom PHP boilerplates or/and outdated PHP patterns (aka, &lt;a href="https://refactoring.guru/design-patterns/singleton"&gt;single ton&lt;/a&gt;) is what we have for work in mostly cases, if not, hacky ways to integrate frameworks as &lt;a href="https://roots.io/acorn/"&gt;Laravel itself&lt;/a&gt; or parts of it to leverage a better code structure.&lt;/p&gt;

&lt;p&gt;Orkestra itself does not contain WordPress connections, this part will be released soon with &lt;a href="https://github.com/Luc-cpl/orkestra-wp"&gt;Orkestra WP&lt;/a&gt;, a package that will contain a proxy structure to easily convert a Orkestra application into a WordPress plugin just by changing the service providers.&lt;/p&gt;

&lt;p&gt;So this framework is not builded to "replace" Laravel and other great options but to be a well structured, fast and light option to build well designed software for situations were a more lightweight and tailored solution is needed to fast develop. While Laravel and other frameworks offer robust features and extensive toolsets, they may be overkill for certain projects or keep their extensibility sourounded by their only ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  So how to start a new project?
&lt;/h2&gt;

&lt;p&gt;To easily start a new project, we also have a skeleton that will initiate the codebase with just a few question and that will be incremented with time adding more templates as "react", "wordpress" and options containing datatbase ORM and user repositories which will allow you to easily launch more complex PHP applications in a standard way.&lt;/p&gt;

&lt;p&gt;So to start you only need PHP 8.2+ and composer installed, then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer create-project luccpl/orkestra-skeleton &lt;span class="o"&gt;{&lt;/span&gt;project_name&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change &lt;code&gt;{project_name}&lt;/code&gt; to your project name, then you just need to answer the questions to create your application.&lt;/p&gt;

&lt;p&gt;After this you will end up with the following codebase inside the created directory:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngalxgrgtwzferaoy1ov.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fngalxgrgtwzferaoy1ov.png" alt="Vanilla template structure" width="800" height="631"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see this template will add and configura the &lt;a href="https://pestphp.com/"&gt;Pest&lt;/a&gt; test suite with a custom TestCase class that will start the application for your tests, making easy to test your application services (as used by Orkestra itself) and you will see a basic application, with a single route in the file &lt;code&gt;config/routes.php&lt;/code&gt; that calls a Controller that simply render a &lt;a href="https://twig.symfony.com/"&gt;Twig&lt;/a&gt; view.&lt;/p&gt;

&lt;p&gt;Now you can go to the root directory in a terminal and run our CLI application to start the server on port :3000.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;php maestro app:serve
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefsins6qsoo825td45cp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fefsins6qsoo825td45cp.png" alt="The Orkestra application start page" width="800" height="272"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With this ready you can start building your application by following the &lt;a href="https://github.com/Luc-cpl/orkestra/wiki"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I recommend you to also follow a &lt;a href="https://blog.mnavarro.dev/the-repository-pattern-done-right"&gt;repository pattern&lt;/a&gt; in your application, to keep best principles and your application easy to mantain and use our &lt;strong&gt;Orkestra\Entities\AbstractEntity&lt;/strong&gt; and the &lt;strong&gt;Orkestra\Entities\EntityFactory&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Orkestra presents a fresh approach to PHP development, offering a seamless integration with WordPress on the horizon. While not aiming to replace established frameworks like Laravel, it provides a lightweight, extensible solution for projects where a tailored, efficient codebase is preferred.&lt;/p&gt;

&lt;p&gt;Starting a new project is made simple with the Orkestra skeleton, initiating you with a clean structure and options for further customization.&lt;/p&gt;

&lt;p&gt;Thanks for reading and see you in next updates.&lt;/p&gt;

</description>
      <category>php</category>
      <category>news</category>
      <category>orkestra</category>
      <category>opensource</category>
    </item>
    <item>
      <title>XDebug with WP-Setup</title>
      <dc:creator>Lucas Carvalho</dc:creator>
      <pubDate>Wed, 24 Apr 2024 23:11:16 +0000</pubDate>
      <link>https://dev.to/lucascarvalhopl/xdebug-with-wp-setup-1hkg</link>
      <guid>https://dev.to/lucascarvalhopl/xdebug-with-wp-setup-1hkg</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;WP Setup has been updated to version 1.1.0, introducing &lt;a href="https://xdebug.org/"&gt;Xdebug&lt;/a&gt; support and allowing for easy generation of test coverage reports.&lt;/p&gt;

&lt;p&gt;Additionally, some small fixes and improvements were made, such as using the &lt;a href="https://www.npmjs.com/package/adm-zip"&gt;adm-zip&lt;/a&gt; library instead of &lt;a href="https://www.npmjs.com/package/unzipper"&gt;unzipper&lt;/a&gt;, providing a simpler and reliable extractor that avoids uncompress errors as with &lt;a href="https://br.wordpress.org/plugins/query-monitor/"&gt;Query Monitor&lt;/a&gt; (that we add by default in wp-setup.json during the initialization process) that in some cases did not complete the unzip process correctly, causing errors during WordPress loading.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running XDebug
&lt;/h2&gt;

&lt;p&gt;Now we can simple start the containers with XDebug running by adding a &lt;code&gt;--xdebug&lt;/code&gt; flag in the start command. This will restart all server and CLI containers with the xdebug up and running.&lt;/p&gt;

&lt;p&gt;You can use the recommended scripts in wp-setup &lt;a href="https://www.npmjs.com/package/wp-setup"&gt;readme&lt;/a&gt; to easily start with the command &lt;code&gt;npm run env:start:xdebug&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;With this, you can use XDebug in all environments, enabling debugging of CLI commands, tests (facilitating a better TDD approach in development), and normal HTTP executions through the server.&lt;/p&gt;

&lt;p&gt;To only stop the XDebug when not needed, you can run the stop command with the flag &lt;code&gt;--xdebug&lt;/code&gt; or with our package scripts run &lt;code&gt;npm run env:stop:xdebug&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mapping directories
&lt;/h3&gt;

&lt;p&gt;As we are running inside docker containers, we need to map our local directories with the container ones so we can fully use the debugger with our IDE.&lt;/p&gt;

&lt;p&gt;In &lt;a href="https://code.visualstudio.com/"&gt;VSCode&lt;/a&gt; for example this can be easily done by adding the following &lt;code&gt;.vscode/launch.json&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0.2.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"configurations"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Listen for XDebug"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"php"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"request"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"launch"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"port"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;9003&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"pathMappings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="nl"&gt;"/var/www/html/wp-content/plugins/my-plugin"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"${workspaceFolder}/plugins/my-plugin"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Replace the pathMappings with your project directories accordingly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With this we can go to VSCode debug tab and click in "Listen for XDebug".&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xph5y93kscc5k7rvv50.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6xph5y93kscc5k7rvv50.png" alt="Go to VSCode debug tab and click in " width="408" height="278"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Tests coverage repport
&lt;/h2&gt;

&lt;p&gt;An important aspect of any development project is to measure how much of our code is tested. This allows us to gauge the reliability of our codebase before sending it to production.&lt;/p&gt;

&lt;p&gt;The CLI test container now starts with XDebug in "coverage" mode by default, enabling the generation of this report.&lt;/p&gt;

&lt;p&gt;Currently, it is not possible to run &lt;code&gt;--coverage&lt;/code&gt; directly with our &lt;code&gt;global-pest&lt;/code&gt; command, to use the cli coverage (very usefull to enforce a &lt;a href="https://pestphp.com/docs/test-coverage#content-minimum-threshold-enforcement"&gt;minimal test coverage&lt;/a&gt; in CI processes) you need to require pest and &lt;code&gt;yoast/phpunit-polyfills&lt;/code&gt; locally in your project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;composer require &lt;span class="nt"&gt;--dev&lt;/span&gt; pestphp/pest yoast/phpunit-polyfills
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then you can run your tests with your locally installed pest with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx wp-setup run &lt;span class="nt"&gt;-w&lt;/span&gt; &lt;span class="nb"&gt;.&lt;/span&gt; wp-test-cli ./vendor/bin/pest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will give you full pest CLI access and allow the use of &lt;code&gt;--coverage&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsfmztl3s97ff6t6biol1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsfmztl3s97ff6t6biol1.png" alt="Pest coverage test" width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This latest update, introduces important enhancements, which are designed to streamline and enhance your WordPress development experience. While the new features enhance the local development process by introducing powerful debugging and testing capabilities, it is important to note that the WP Setup is not yet fully optimized for running CI processes directly. However, the groundwork has been laid, paving the way for future enhancements that will support more robust CI integrations.&lt;/p&gt;

&lt;p&gt;As the sole developer behind WP Setup, I invite other developers to explore the potential of this tool. Your feedback and contributions are invaluable to not only improve its existing features but also to help in expanding its capabilities. The project is open for contributions on &lt;a href="https://github.com/Luc-cpl/wp-setup"&gt;GitHub&lt;/a&gt;, and I am eager to collaborate with other developers to make WP Setup even more powerful and versatile.&lt;/p&gt;

&lt;p&gt;Please take this opportunity to test &lt;a href="https://www.npmjs.com/package/wp-setup"&gt;WP Setup&lt;/a&gt;. Together, we can work towards making a comprehensive development tool that better serves the WordPress community.&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>news</category>
      <category>php</category>
      <category>testing</category>
    </item>
    <item>
      <title>Wordpress tests with Pest and WP Setup</title>
      <dc:creator>Lucas Carvalho</dc:creator>
      <pubDate>Wed, 17 Apr 2024 23:55:34 +0000</pubDate>
      <link>https://dev.to/lucascarvalhopl/wordpress-tests-with-pest-and-wp-setup-2cho</link>
      <guid>https://dev.to/lucascarvalhopl/wordpress-tests-with-pest-and-wp-setup-2cho</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In my last post &lt;a href="https://dev.to/lucascarvalhopl/introducing-wp-setup-11fb"&gt;here&lt;/a&gt;, I presented my new WordPress environment tool called &lt;strong&gt;&lt;a href="https://www.npmjs.com/package/wp-setup"&gt;WP Setup&lt;/a&gt;&lt;/strong&gt;, and at that moment it was missing a test environment.&lt;/p&gt;

&lt;p&gt;Today, I finished the first implementation of this environment, adding &lt;a href="https://pestphp.com/"&gt;Pest&lt;/a&gt; and &lt;a href="https://phpunit.de/index.html"&gt;PHPUnit&lt;/a&gt; in v10.5, which is currently not supported by default with &lt;a href="https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/"&gt;WP Env&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, let's put our hands a little bit into the code and see how to start doing tests with &lt;strong&gt;WP Setup&lt;/strong&gt; and &lt;strong&gt;Pest&lt;/strong&gt; in a few steps creating a basic plugin.&lt;/p&gt;

&lt;h2&gt;
  
  
  The plugin basis
&lt;/h2&gt;

&lt;p&gt;To build this simple example, create a directory called &lt;code&gt;my-plugin&lt;/code&gt; with just a &lt;code&gt;my-plugin.php&lt;/code&gt; file containing the &lt;a href="https://developer.wordpress.org/plugins/plugin-basics/header-requirements/"&gt;WP header requirements&lt;/a&gt;.&lt;/p&gt;

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

&lt;p&gt;Then, start an &lt;a href="https://npmjs.com/"&gt;npm&lt;/a&gt; project in this directory by typing &lt;code&gt;npm init -y&lt;/code&gt; in a terminal.&lt;/p&gt;

&lt;p&gt;Now we just need to add WP Setup as a &lt;strong&gt;development package&lt;/strong&gt; by typing the following command in the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;wp-setup &lt;span class="nt"&gt;--save-dev&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And in the &lt;code&gt;scripts&lt;/code&gt; section of the created &lt;code&gt;package.json&lt;/code&gt; file, add the json bellow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"scripts"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"wp-setup"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup start"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:stop"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup stop"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:destroy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup destroy"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:run"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup run"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:wp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup wp"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:help"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup help"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:composer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup run wp-cli --workdir . composer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"env:pest"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"wp-setup run wp-test-cli --workdir . global-pest"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The init command
&lt;/h2&gt;

&lt;p&gt;In this last update, the &lt;code&gt;init&lt;/code&gt; command was added, and with this, it's now only two commands to set up the environment.&lt;/p&gt;

&lt;p&gt;Create the &lt;code&gt;wp-setup.json&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run wp-setup init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create the test configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run wp-setup &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--tests&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After this, you will end up with this structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fme01m0vf10fmg2wm8mib.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fme01m0vf10fmg2wm8mib.png" alt="Basic plugin structure" width="800" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Starting the environment
&lt;/h2&gt;

&lt;p&gt;Now, we are fully set up and just need to start the environment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Please, be sure to have the ports :80 and :443 available on your machine and &lt;a href="https://www.docker.com/get-started/"&gt;Docker&lt;/a&gt; started.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run &lt;span class="nb"&gt;env&lt;/span&gt;:start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a while, you can visit your environment at &lt;code&gt;https://my-plugin.localhost&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjxw8sjdmx984r0im4qn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frjxw8sjdmx984r0im4qn.png" alt="Default WordPress Site Homepage" width="800" height="435"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finally running the tests
&lt;/h2&gt;

&lt;p&gt;Now that all is up and running, we can start our tests with Pest by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run &lt;span class="nb"&gt;env&lt;/span&gt;:pest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;As you can see, the example tests ran as expected, and you can create new tests following the &lt;a href="https://pestphp.com/docs/"&gt;Pest documentation&lt;/a&gt; and the &lt;a href="https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/"&gt;WordPress Tests Handbook&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stopping the environment
&lt;/h2&gt;

&lt;p&gt;Now that we've finished our work here, we can stop our environment, removing the existing Docker containers and freeing the used ports. The images and development volumes will persist on your machine, making it fast to start again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run &lt;span class="nb"&gt;env&lt;/span&gt;:stop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, if you prefer, you can destroy the entire environment by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run &lt;span class="nb"&gt;env&lt;/span&gt;:destroy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope this simple tutorial helps you effectively utilize &lt;strong&gt;WP Setup&lt;/strong&gt; with Pest for your WordPress development projects.&lt;/p&gt;

&lt;p&gt;If you have any questions or need further assistance, please feel free to comment out here. Happy coding!!!&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>pest</category>
      <category>php</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introducing WP Setup</title>
      <dc:creator>Lucas Carvalho</dc:creator>
      <pubDate>Sat, 13 Apr 2024 23:38:17 +0000</pubDate>
      <link>https://dev.to/lucascarvalhopl/introducing-wp-setup-11fb</link>
      <guid>https://dev.to/lucascarvalhopl/introducing-wp-setup-11fb</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Developing WordPress plugins and themes often requires a reliable development environment. Current we have good solutions as &lt;a href="https://developer.wordpress.org/block-editor/reference-guides/packages/packages-env/"&gt;wp-env&lt;/a&gt; from Autommatic, &lt;a href="https://localwp.com/"&gt;Local WP&lt;/a&gt; from WP Engine, &lt;a href="https://www.docker.com/"&gt;Docker&lt;/a&gt;, &lt;a href="https://www.apachefriends.org/"&gt;XAMPP&lt;/a&gt; (for old ones) and so on. All this can be good suits for a development environment, specially Local WP that is probably the easiest one to get up and running and wp-env that leverages Docker as a development environment in a very easy way to use.&lt;/p&gt;

&lt;p&gt;After use most of existing options and find some barriers in specific cases, I decided to create my own solution, leveraging Docker as wp-env but allowing more flexibility and customization for advanced use cases.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a new tool?
&lt;/h2&gt;

&lt;p&gt;Until some months ago I was using Local WP as my go-to solution in most of my projects and in a specific and more advanced one, Docker with Docker Compose to create a custom environment. Recently I started to use wp-env and I was very impressed with the simplicity and power of this tool, also to easily configure a test environment with PHPUnit by default, but again, in a specific use case I found a limitation that makes me get back to Docker and Docker Compose and lost some time to configure my environment as I need.&lt;/p&gt;

&lt;p&gt;In this last and specific case I was working with a Laravel application that needs to interact with a WordPress site, and as both works from different Compose projects, I need to add a custom configuration to allow internal requests between them, what get easy to do with Laravel Sail, simply adding a &lt;code&gt;extra_hosts&lt;/code&gt; configuration to the &lt;code&gt;docker-compose.yml&lt;/code&gt; file but was impossible to do with wp-env and probably will not be implemented as we can see from &lt;a href="https://github.com/WordPress/gutenberg/issues/25486"&gt;this Github issue&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, I decided to create my own solution, leveraging a similar approach to wp-env but allowing more flexibility and customization, also removing some custom scripts that I need to further customize my environment (as configuring WordPRess Multisite).&lt;/p&gt;

&lt;h2&gt;
  
  
  Meet WP Setup
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/wp-setup"&gt;WP Setup&lt;/a&gt; is a simple and powerful tool to create a WordPress development environment using Docker and Docker Compose, providing a simple CLI tool that allows you to create a new WordPress project in a few seconds.&lt;/p&gt;

&lt;p&gt;Currently it should be used as a node development dependency and can be easily installed using npm, pnpm or yarn.&lt;/p&gt;

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

&lt;p&gt;Currently these are the main available features of WP Setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a new WordPress environment in a few seconds&lt;/li&gt;
&lt;li&gt;Customize your environment using a simple configuration file or CLI options&lt;/li&gt;
&lt;li&gt;Allow inject custom Docker Compose file to override the default one, allowing you to customize your environment as you need (add custom services, volumes, networks, etc)&lt;/li&gt;
&lt;li&gt;Easily configure &lt;strong&gt;Wordpress Multisite&lt;/strong&gt; with subdomains or subdirectories&lt;/li&gt;
&lt;li&gt;Uses the new &lt;a href="https://frankenphp.dev/"&gt;FrankenPHP&lt;/a&gt; server to add &lt;strong&gt;SSL support&lt;/strong&gt; to your local environment&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Under development
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;The Test environment with PHPUnit and Pest is ready and you can see &lt;a href="https://dev.to/lucascarvalhopl/wordpress-tests-with-pest-and-wp-setup-2cho"&gt;here&lt;/a&gt; how to start using&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is a new tool and is under development. These way some features are not implemented yet, as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test environment&lt;/strong&gt; with PHPUnit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build environment&lt;/strong&gt; to easily build your project for production&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Xdebug&lt;/strong&gt; support&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composer CLI&lt;/strong&gt; to easily run composer commands in your WordPress project without the need to enter in the container or even have PHP installed in your machine&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sync Hosts&lt;/strong&gt; to automatically add your development domain to your hosts file&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My priority at this moment is to implement the test environment with PHPUnit and Xdebug support, as I need this in my daily work, but I'm open to suggestions and contributions.&lt;/p&gt;

&lt;p&gt;Also I'm looking into the possibility to use &lt;a href="https://developer.wordpress.org/block-editor/reference-guides/packages/packages-hooks/"&gt;WordPress JS Hooks&lt;/a&gt; to allow further customization of the environment (aka adding environment plugins). This can be useful to standardize the creation and configuration of different services and tools in the environment, such as MailHog, Redis, etc.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give it a try
&lt;/h2&gt;

&lt;p&gt;I invite you to give WP Setup a try for your WordPress development projects. Whether you're a novice or an advanced user, WP Setup aims to simplify your workflow while offering the flexibility you need.&lt;/p&gt;

&lt;p&gt;For detailed installation instructions and to start using WP Setup, visit &lt;a href="https://www.npmjs.com/package/wp-setup"&gt;this link&lt;/a&gt;. Your feedback and contributions will help to improve and expand the capabilities of WP Setup. Let's make WordPress development smoother and more efficient together!&lt;/p&gt;

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