How to Install, Configure, and Debug Magento 2 code with XDEBUG & PHPSTROM.
PHPStorm is one of the best IDE from JetBrains for PHP web development. In this article, I am going to show you how to install PHPStorm on Ubuntu 20.04 LTS. So, let’s get started.
Installing Ubuntu Make
You can easily install PHPStorm IDE using Ubuntu Make on Ubuntu 20.04 LTS. Ubuntu Make is available in the official package repository of Ubuntu 20.04 LTS.
Now, install Ubuntu Make with the following command:
To confirm the installation, press Y and then press <Enter>.
Now, run the following command to check if the umake command is available:
You can easily install PHPStorm using the following umake command:
At this point, PHPStorm should be installed.
Now, add execute permission to the PHPStorm desktop file as follows:
Finally, reboot your computer for the changes to take effect.
Execute the below command after given the permission.
Once your computer boots, you can access PHPStorm from the Application Menu of Ubuntu 20.04 LTS.
Now, Click on New Project.
Select from your computer and set the location.
After clicking on Open button, You’ll see the below display.
Now, let’s install Magento Coding Standard.
Moreover, You’ve to install Magento Coding Standard.
GO through google
Search for how to install magento coding standard using Github repo.
Execute the highlighted command.
You can also install via composer.
Now Installation is completed.
How To verify its Installed or not?
Execute the below command to verify.
How to configure Magento Coding Standard with PHPSTROM
Go To the PHPSTROM.
Go through FIle -> Setting -> Language & Framework -> PHP -> Quality Tools -> PHP Codesniffer
Go through FIle -> Setting ->Editor -> Inspections -> PHP_CodeSniffer validation -> Coding Standard —- Select Magento 2
Now Click on Apply Button.
Why do we need Xdebug?
In the development process, we have several existing codes with a number of functionalities. We don’t have to create that functionality from the core every time. We can rather use the existing code and make simple modifications that will save our time and energy. Product development processes work the same. Before modifying the existing code, we need to know how they work and which codes have which functionality.
How To install Xdebug
- Now, moving ahead to install the Xdebug.
How to install it?
Lets’s have a look on it.
Execute the below commands for the installation of Xdebug.
- sudo apt -y install php7.4-dev php-pear
- sudo pecl channel-update pecl.php.net
- sudo apt update
- sudo apt install php-xdebug
- php -v
- sudo nano /etc/php/7.4/cli/conf.d/20-xdebug.ini
- sudo service apache2 restart
Now, You’ve successfully configured the Xdebug.
Let’s Have a look on How it works.
In that article we tried to explain how PHP storm, Magento coding standard, and XDebug work & install, I think this is crucial for using it. Furthermore, it is always worth it to understand how things work under the hood.
The configuration described in that article is only one possible way, that works well in my case. If you have another situation, you may need another configuration. Anyway, if you have problems with configuring XDebug, please feel free to ask below in the comments. This debugging of code using Xdebug and PhpStorm can be beneficial for your development in the debug process, thus helping you save the amount of time spent searching on Google.
Do you want to receive a free consultation about how to optimize your store and generate more sales? Reach us out at [email protected] or contact us, and we will be more than happy to help you out.