The growing unpopularity of Windows-based laptops among web-developers in the past has its roots. If you are lucky enough, you may meet a dev who uses a Windows-based laptop as a working station but it’s rather a rare exception to the rule. And at every table, along with 10 developers with serious faces, you saw at least 7 MacBooks and 3 with Ubuntu on board. An essential part of a working toolkit at such events is, obviously, a laptop (there were gurus that wrote the code even on tablets but that’s a different story). Have you finished all these setup with ease? Great job! In the second part we will discuss more about how to debug Magento 2 code effectively with Xdebug and PhpStorm.Before COVID-19 cut the possibility of public gatherings, we had plenty of offline hackathons or contribution days in the Magento community world. Now there are two ways that you can get started with debugging, first way is clicking on the green bug, then a new browser page will load up and you can start your debugging from that pointĪlternatively, you can install xdebug helper extensions for browsers, Chrome and Firefox, so that it can send debugging signal out to PhpStorm to catch it. It means your PhpStorm is ready to listen to debug signals PhpStorm debug tab Then look at the upper right corner, you will see the debug listener is now clickable. Setup Magento Application that you want to debug Save the config, then go to Run -> Debug Configuration and add a PHP Web Application debug config. Additionally, you can set up several ones if you want. Then go to Servers and set up a debug server. In PhpStorm windows, you need to go to File -> Settings -> Languages & Frameworks -> PHP and set the CLI interpreter Set correct CLI Interpreter for Php In order to use Xdebug to debug Magento 2, you have to setup it with your IDE (in our case it is PhpStorm). Now take a look again at phpinfo, if you can see this part then it is configured correctly Your Xdebug configuration Setup XDebug with PhpStorm You will need to restart apache to apply the changes: If you are running on php 7 then it would be /usr/lib/php7/20131226/xdebug.so The number might change depending on your machine. One thing worth mentioning is the zend_extension variable. Go there and paste the following code into the end of the file Go check your info.php again, look for this line where you can get the php.ini file location Find your php.ini path ![]() However we need to add some config script to setup Xdebug locally. Now to install xdebug, open terminal and type in the following command: Then go to 127.0.0.1/info.php, the following screen should display: A sample Phpinfo page Install XDebugįrom now on we assume you have your web server running Ubuntu locally on /var/there, with the content: Ready? Let’s start with the most important thing: Install XDebug. Also note that the IDE we use in this article is PhpStorm. In this article together we will try to install and config Xdebug, since it is more popular and easier to use. To debug Magento 2 code, you can use either XDebug or Zend Debug. ![]() ![]() Predictably, correctly debug your application will save you tons of time and effort. Some developers like to log things out, some like to print it right on the screen, but most prefer run-time debugging. Debugging is critical in the development process of any system.
0 Comments
Leave a Reply. |