How to Use Composer and Autoload in PHP
Tags: wordpress
Published: 2020-12-15 03:56:21

<!-- wp:paragraph -->

<p>When working with PHP projects, developers often have to manage many libraries from third parties. But installing and updating these libraries are quite complicated. To solve this problem, you can use Composer and Autoload to save time and effort.</p>

<p><!--more--></p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Now, let's find out <strong>what Composer and Autoload are, and how to use them in PHP</strong>!</p>

<p><img class="aligncenter" src="https://i.imgur.com/M57R2ua.jpg" alt="How to Use Composer and Autoload in PHP" width="6000" height="4000" /></p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>What is Composer?</h2>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Composer is a tool for <strong>dependency management in PHP</strong>. In simple words, Composer is used for <strong>managing libraries in your PHP project</strong>.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Composer allows you to declare the libraries in your PHP projects, automatically load the code of the libraries, create and add necessary files to the PHP projects, and update libraries when they have new versions.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>Common Problems in Libraries Management</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>If you don't use Composer, when you work with PHP projects, you will have to deal with many problems in library management.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>First, to use the external libraries, you need to download and move them to the PHP project folder. However, <strong>the installation is fairly complicated and difficult to remember</strong>.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Besides, there are many situations where some libraries depend on others. Therefore, <strong>updating them takes you a lot of time and effort</strong> because you have to find the original library. For example, library A depends on library B, and if library B has a new version, you will have to find and update it at library A first.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Now, thanks to Composer, the above problems can be solved easily!</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>Benefits of Composer</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Composer offers developers two main benefits:</p>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li>Help developers centrally manage third-party libraries as well as their versions simply and quickly with the <code>composer.json</code> file.</li>

<li>Automatically search and update new versions of libraries that are necessary for PHP projects.</li>

</ul>

<!-- /wp:list -->

<!-- wp:heading {"level":3} -->

<h3>Install and Activate Composer</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>To install and activate Composer, just follow these steps:</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Check If PHP has been Installed</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>First, you need to install PHP. To check if PHP has been installed, enter the following command in the <code>terminal</code>:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>php -v</pre>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Install Composer on Windows</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Installing Composer on Windows is very easy and quick. You just need to download the <a href="https://getcomposer.org/Composer-Setup.exe">Composer-Setup.exe</a> file, and then run it.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>By default, Composer adds its path to the <code>PATH</code> environment variable of the system so that you can call the <code>composer</code> command from anywhere. However, if you can't run the composer command, add the <code>C:\ProgramData\ComposerSetup\bin</code> value to the <code>PATH</code> environment variable of the system.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Install Composer on CentOS/RHEL/Ubuntu</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Go to <code>terminal</code> and enter the following command to install Composer:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>sudo curl -sS https://getcomposer.org/installer | php</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Still in the <code>terminal</code>, enter this command to allow calling the <code>composer</code> command from anywhere:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>mv composer.phar /usr/local/bin/composer</pre>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>Some General Commands</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>When working with Composer, you need some general commands below:</p>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li>Check the current version of Composer:</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<pre>composer -v</pre>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li>Update the latest version of Composer:</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<pre>composer -selfupdate</pre>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li>Clear the Cache memory of Composer (to force Composer to reload libraries in the Cache memory):</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<pre>composer clearcache</pre>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li>Search for library packages:</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<pre>composer search library_name</pre>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>How to Use Composer in PHP Projects</h3>

<!-- /wp:heading -->

<!-- wp:heading {"level":4} -->

<h4>Set Up Composer for New PHP Projects</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>The first thing you need to do is creating the <code>composer.json</code> file. This file contains all the data of setting up Composer for the project. This can be done by adding the following command to the <code>terminal</code>:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer init</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>After that, you need to declare the <code>composer.json</code> file as follows:</p>

<!-- /wp:paragraph -->

<pre>Package name (/) [admin/my_project]: vendor/myproject (/*this is the library name/*/)

Description []: How to use Composer in PHP

Author [elightup &lt;elightup@gmail.com&gt;, n to skip]: elightup&lt;elightupr@gmail.com&gt;1

Minimum Stability []: dev

Package Type (e.g. library, project, metapackage, composer-plugin) []:

License []:

Define your dependencies.

Would you like to define your dependencies (require) interactively [yes]? no

Would you like to define your dev dependencies (require-dev) interactively [yes]? No

Do you confirm generation [yes]? Y

</pre>


<p>Done! I've finished creating the <code>composer.json</code> file with the following content:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>{

    "name": "vendor/myproject",

    "description": "How to use Composer in PHP",

    "authors": [

        {

            "name": "elightup",

            "email": "elightup@gmail.com"

        }

    ],

    "minimum-stability": "dev",

    "require": { }

}

</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>From now on, Composer settings (includes settings for libraries) will be saved in this <code>composer.json</code> file.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Integrate Libraries into the PHP Project with Composer</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>First, you need to determine which libraries your PHP project needs by searching them <a href="https://packagist.org/">here</a>. Once you've determined the libraries that your PHP project needs to use, integrate them into your PHP project with Composer by two methods below:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p><strong>Method 1: Enter a Command on the <code>terminal</code></strong></p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For instance, I want to use the latest version of the <code>phpro/grumphp</code> library (it's used for checking the code quality). Therefore, I enter the following command into the <code>terminal</code>:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer require phpro/grumphp</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>This command will require Composer to download the <code>phpro/grumphp</code> library. This library will be saved in the <code>vendor</code> file in your PHP project.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>In addition, the <code>vendor/autoload.php</code> file is automatically created. This file is used for autoloading libraries for the PHP project.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Go back to the <code>composer.json</code> file, the following code will show up in the file:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>"require": {

        "phpro/grumphp": "^0.19.1"

    }

</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Explanation:</p>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li><code>phpro/grumphp</code> is the library used for the PHP project.</li>

<li><code>0.19.1</code> is the current version of the library.</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<p>From now on, when you want to share your PHP project, just copy only the <code>composer.json</code> file instead of the whole <code>vendor</code> folder. When you paste the <code>composer.json</code> file to another computer, Composer will automatically update the <code>vendor</code> folder.</p>

<!-- wp:paragraph -->

<p><strong>Method 2: Enter a Command in the <code>composer.json</code> </strong><strong>file</strong></p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Instead of entering a command directly from the <code>terminal</code> as method 1, you can edit the description of the <code>whoops</code> library in the <code>composer.json</code> file by adding the code with the following content into the <code>require</code> section:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>"library-name":"^the-smallest-version"</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, I want to integrate the <code>phpro/grumphp</code> library version 0.19.1 into Composer, so I fill in the <code>require</code> section with the following content:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>"require": {

       "phpro/grumphp": "^0.19.1",

    }

</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>After that, enter the <code>composer update</code> to install the library. This command will automatically update the latest version of some libraries that are necessary for the PHP project.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>The advantage of this second method is that you can list all libraries before entering the <code>composer update</code> command. Therefore, this method is very convenient when you need to install many libraries at once.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>To use these above libraries for the project, you just need to enter the <code>include vendor/autoload.php</code> command to the <code>index.php</code> file in the PHP project.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Remove a Library from the PHP Project</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>To remove a library that was already integrated into a PHP project (saved in the <code>vendor</code> file), you can follow one of two methods:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p><strong>Method 1: Using the <code>composer</code></strong><strong><em> </em></strong><strong>command</strong></p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>From the <code>terminal</code>, enter the following command:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer remove vendor/package</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>In this command, <code>vendor/package</code> is the name of the library you want to remove. For example, I want to remove the <code>phpro/grumphp</code> library, so the command will be like this:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer remove phpro/grumphp</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p><strong>Method 2: Update the <code>composer.json</code></strong><strong><em> </em></strong><strong>file </strong></p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Just go to the <code>composer.json</code> file, navigate to the <code>require</code> section, delete the folder you want (for instance, <code>phpro/grumphp</code>), and then enter the <code>composer update</code> command.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>Specify Versions for Libraries in Composer</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>In some cases, developers don't need to use the latest version of the library but just need to use a certain version. To do that, you can specify versions for the libraries in Composer using 6 methods below:</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Version Range</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>This method uses comparison operators such as <code>&gt;</code>, <code>&lt;</code>, <code>&gt;=</code>, <code>&lt;=</code>, <code>!=</code>, <code>AND</code>, <code>OR</code> to specify the range of valid versions that Composer can use. The <code>AND</code> operator is represented by commas or spaces, and the <code>OR</code> operator is represented by two vertical lines (<code>||</code>).</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, to specify that Composer is only allowed to use versions before version 0.19 and not allowed to use version 0.17 of the <code>phpro/grumphp</code> library, I enter the following command to the <code>terminal</code>:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer require phpro/grumphp "&lt;0.19,!=0.17"</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Explanation:</p>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li><code>phpro/grumphp</code>: the name of the library.</li>

<li><code>&lt;0.19</code>: Composer is only allowed to use versions before 0.19.</li>

<li><code>!=</code>: Composer is only allowed to use versions except 0.17.</li>

<li><em><code>,</code></em> is treated as the <code>AND</code> operator.</li>

</ul>

<!-- /wp:list -->

<!-- wp:heading {"level":4} -->

<h4>Wildcard Versions</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>This method is used to require Composer to use only the library versions in the range of <code>x.x.*</code>.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, if I use the <code>composer require phpro/grumphp "0.18.*"</code> command, Composer is only allowed to use the versions after the version 0.18 and before the version 0.19 (like 0.18.1, 0.18.2, ...) of the <code>phpro/grumphp</code> library. This is similar to the use of the <code>"&gt;=0.18 &lt;0.19"</code> command in the Version Range method.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Hyphen Ranges</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>This method uses the <code>-</code> operator to determine the range. For better understanding, look at the below example.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>I want to require Composer to only use versions after version 0.1 and before version 0.19 of the <code>phpro/grumphp</code> library. Therefore, I enter the <code>composer require phpro/grumphp "0.1 - 0.18"</code> command. The range includes 0.18.1, 0.18.2, ... It's similar to <code>"&gt;=0.10 &lt;0.19"</code>.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Tiddle Range</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>This method uses the <code>~</code><strong><em> </em></strong>operator. For example, if you enter <code>"~0.18"</code>, Composer will only use the versions after the 0.18 (except 0.18) and before the 1.0. It's similar to <code>"&gt;0.18 &lt;1.0"</code>.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Caret Range</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>This method uses the <code>^</code> operator to specify that Composer is only allowed to use library versions from the version that is entered (not including itself).</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, if I enter <code>^0.18.1</code>, Composer will only use the library versions after the 0.18.1 (except <code>0.18.1</code>).</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":4} -->

<h4>Dev-Master</h4>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>When you use the Dev-Master method, your libraries will always be in the latest available versions. However, it comes with a lot of risks because the latest versions may not be finalized and they can have some bugs.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, to require Composer to always use the latest version of the <code>phpro/grumphp</code> library, I enter the <code>composer require phpro/grumphp "dev-master"</code> command.</p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>Autoload</h2>

<!-- /wp:heading -->

<!-- wp:heading {"level":3} -->

<h3>What is Autoload?</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Autoload is a method to load and use classes. Using Autoload, we can load and call classes everywhere instead of including classes at the beginning of each PHP file. Therefore, we don't need to load all classes in the library for all PHP files.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>As I mentioned above, Composer makes library management convenient and quick. Besides, Autoload is an extremely useful tool that helps Composer easily manage the dependencies between libraries packages.</p>

<!-- /wp:paragraph -->

<!-- wp:heading {"level":3} -->

<h3>How Does Autoload Work?</h3>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>To understand how Autoload works, you need to learn about the <strong>PSR-4</strong> standard first. This is a recommended PHP coding standard for libraries.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Below is the content of the <strong>PSR-4 </strong>standard:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Code in folders should be organized properly so that every class can be referenced. To do that, developers need to build classes according to the following structure:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>\&lt;NamespaceName&gt;(\&lt;SubNamespaceNames&gt;)*\&lt;ClassName&gt;</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>When developers build a class according to the above structure, the class can be referenced by a line of code with three components: <code>NameSpace</code>, <code>SubNameSpaces</code>, and <code>ClassName</code>.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Explanation:</p>

<!-- /wp:paragraph -->

<!-- wp:list -->

<ul>

<li><code>NameSpace</code>: the name of the <code>vendor</code> and the required prefix named by yourself. Especially, it mustn't have a similar name to other vendors.</li>

<li><code>SubNameSpaces</code>: The child namespaces (following the first namespace - vendor). From the <code>SubNameSpaces</code>, the path of the class will correspond to the structure of the folder where the code is stored. For example, you save the code of the library in the original folder <code>src</code> and call one of your classes that is <code>cls1</code> with the <code>\myvendor\namespace1\namespace2\cls1</code> syntax. It means that there is a <code>namespace1</code> folder in the src folder, and there is a <code>namespace2</code> folder in the <code>namespace1</code> folder.</li>

<li><code>ClassName</code>: This is the name of the created class. It's required. Besides, you need to name the PHP file like the <code>ClassName</code> in the folder that corresponds to the last namespace (<code>ClassName.php</code>). This file will define the code of the class.</li>

</ul>

<!-- /wp:list -->

<!-- wp:paragraph -->

<p>All the PHP projects have to use an Autoload library to load the above structure when needed. <strong>Frameworks that have the same Autoload mechanism can reuse libraries of each other</strong>. Nowadays, almost all the PHP frameworks use the same Autoload mechanism according to PSR-4.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Composer can <strong>generate autoload code according to PSR-4</strong>. Therefore, this tool can help you <strong>reuse libraries of other PHP projects</strong>.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>For example, I want to create a class named <code>Car</code> with the namespace <code>Vehicle/Listings</code>. Thus, the code of the class will be saved in the <code>src/Listings/Car.php</code> file with the following content:</p>

<!-- /wp:paragraph -->

<pre>&lt;?php

namespace Vehicle\Listings

class Car {

    function listsCar()

    {

//code...

    }

}

</pre>


<!-- wp:paragraph -->

<p>The above code is PSR-4 compliant, so Composer will help you integrate it into the <code>vendor/autoload.php</code> file. To call this class when needed, tell Composer that you have a <strong>PSR-4</strong> <strong>Autoload</strong> module by adding the following code to your <code>composer.json</code> file:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>{

    "autoload": {

        "psr-4": {

            "Vehicle\\": "src/",

         }

    }

}

</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>This code requires namespace level 1 - <code>Vehicle</code> to point to the <code>src/</code> folder. Namespaces level 2 onwards will work the same. For example, the path of the <code>Car</code> class is <code>src/Listings/Car.php</code>. To be clear, <code>src</code> is the file that is pointed by namespace 1, <code>Listings</code> is the file in <code>src</code>, <code>Car.php</code> is the PHP file containing the code of the class.</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>After that, enter the following command to the <code>terminal</code>:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<pre>composer dump-autoload</pre>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>Now, <code>vendor/autoload.php</code> has the mechanism to autoload your code when you need to use it. Henceforth, if you want to use the <code>Car</code> class, just call it by one of two code below:</p>

<!-- /wp:paragraph -->

<!-- wp:paragraph -->

<p>The first code:</p>

<!-- wp:paragraph -->

<pre>&lt;?php

    $cls = new Vehicle\Listings\Car();</pre>

<p>The second code:</p>

<pre>&lt;?php

    use Vehicle\Listings;

    $cls = new Car();</pre>

<p>The two above codes have the same function. They just have different ways of calling, so you can use whichever you want.</p>

<p><img class="aligncenter" src="https://i.imgur.com/cWUmWX1.jpeg" alt="Composer and Autoload are two powerful and indispensable tools in PHP" width="5507" height="3098" /></p>

<!-- /wp:paragraph -->

<!-- wp:heading -->

<h2>Last Words</h2>

<!-- /wp:heading -->

<!-- wp:paragraph -->

<p>Composer and Autoload are two powerful and indispensable tools in PHP. Therefore, you should use them to save time and effort from managing libraries in your project. Hopefully, this article has helped you better understand the two tools and learn how to use them at a basic level. If you have any questions about Composer and Autoload, feel free to share them with us in the comment section!</p>

<p>In addition, you may like our articles on <a href="https://metabox.io/object-pool-pattern/">how to use Object Pool Pattern</a> and <a href="https://metabox.io/php-technique-write-clean-readable-code/">PHP techniques to write clean and readable code</a> in our <a href="https://metabox.io/category/guide/">Guide</a> category.</p>