How to Install, Configure, and Debug Magento 2 code with XDEBUG & PHPSTROM.

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:

No alt text provided for this image

To confirm the installation, press?Y?and then press?<Enter>.

Now, run the following command to check if the?umake?command is available:

No alt text provided for this image

Installing PHPStorm

You can easily install PHPStorm using the following umake command:

No alt text provided for this image

At this point, PHPStorm should be installed.

Now, add execute permission to the PHPStorm desktop file as follows:

No alt text provided for this image

Finally, reboot your computer for the changes to take effect.

Execute the below command after given the permission.

$?sudo?reboot

Once your computer boots, you can access PHPStorm from the Application Menu of Ubuntu 20.04 LTS.

No alt text provided for this image

Now, Click on New Project.

Select from your computer and set the location.

No alt text provided for this image

After clicking on Open button, You’ll see the below display.

No alt text provided for this image

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.

No alt text provided for this image

Now Installation is completed.

How To verify its Installed or not?

Execute the below command to verify.

No alt text provided for this image

How to configure Magento Coding Standard with PHPSTROM

Go To the PHPSTROM.

Go through FIle -> Setting -> Language & Framework -> PHP -> Quality Tools -> PHP Codesniffer

No alt text provided for this image

Go through FIle -> Setting ->Editor -> Inspections -> PHP_CodeSniffer validation -> Coding Standard?—- Select Magento 2

Now Click on Apply Button.

No alt text provided for this image

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 XdebugNow, 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

[xdebug]

zend_extension=”xdebug.so”

xdebug.mode=”debug”

xdebug.start_with_request=trigger

xdebug.client_port=9003

xdebug.log=”/home/d45-bt/logs/xdebug.log”

xdebug.start_with_request=”yes”

  • sudo service apache2 restart

Now, You’ve successfully configured the Xdebug.

Let’s Have a look on How it works.

No alt text provided for this image

Final Words

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.

Born Techies –Digital Commerce agency?offers?Shopify,?Shopware,?Magento, and Bigcommerce development with the latest technologies.

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.

QUERY? LET'S CONNECT!

要查看或添加评论,请登录

Born Techies的更多文章

社区洞察

其他会员也浏览了