A package manager (such as Apt on Linux, Homebrew on macOS, or Chocolatey on Windows).An installation of PHP (I’m using 7.3.10).A recent release of PhpStorm (I’m using 2019.2.3). ![]() You won’t need very much to follow along with this tutorial, just the following: ![]() Getting (remote) debugging setup for web-based applications can be a finicky and intricate affair at times, depending on the structure of your development environment. This article doesn’t cover debugging web-based applications with PhpStorm, but smaller code libraries. So that’s why, in this article, I’m going to show you how to integrate Xdebug, PHPUnit, and PhpStorm. Whenever I write PHP code, it’s reasonably safe to say that I use PhpStorm. Gladly, to set it up in PHP, you don’t need a lot. If you’re not familiar with step-through debugging, it’s where you, as the name implies, step through your code, one line at a time. The solution was to use use step-through debugging in PhpStorm. I needed to know what was being returned, but the ham-fisted way I was attempting to find it wasn’t working. Not only did I not see the value that I wanted, I saw an unwieldy stack trace instead. Well, if you’ve ever tried to var_dump a variable in the middle of a PHPUnit test, then you’ll know that PHPUnit doesn’t take kindly to that. Instinctively ( wrongly) I started using PHP’s var_dump method to attempt to see what the value being returned was. However, in others, the values that I expected to be returned, weren’t. In the early stages of development, in some cases, the tests validated that the expected values were being returned. Have a look at the project’s tests for a full list, but here’s a short list. Not such a tricky request, you might think.īut the more test data I fed the code, the more use cases I found which needed to be handled. Its task is to filter a European-format currency string, such as -1.432.156,54 into its integer equivalent. One example is a package called currency-filter. These dependent packages perform several smaller tasks, ones that don’t belong in the main package. Recently, I’ve been developing a side-project, and have had to create several dependent packages to support it. ![]() In this article, I’ll show you how to set up proper debugging with PhpStorm, Xdebug, and PHPUnit, and give you a modern, sophisticated debugging experience. If I set xdebug.start_with_request = yes in php.ini then debug will work even for Run (or when executing that PHP script outside of IDE) - as long as "phone handle" icon is green (IDE listens for incoming debug requests).Still using var_dump to debug your PHP code? Stop! While var_dump can be convenient, it’s a very blunt approach. As you may see these old style parameters do not affect Xdebug 3 at all. That's what IDE is executing: E:\Projects\php\php74\php.exe -dxdebug.remote_enable=1 -dxdebug.remote_mode=req -dxdebug.remote_port=9001 -dxdebug.remote_host=127.0.0.1 E:\Projects\web\_idetest\test.php. (I have a bit mores settings, but those are customisation for output file names, log locations, extra stuff for quickly turn on some options in some scenarios/when needed etc - these are not needed here and it works fine without them)ĬLI debug initiated from IDE ("PHP Script" type of configuration): This is my php.ini content for Xdebug 3 settings (as simple as this): Yes, IDE sends old-style parameters when initiating debugging for a CLI script (like xdebug.remote_ etc) but the debug still works just fine. and it still works fine in PhpStorm 2020.2.3. I have downloaded Xdebug 3.0.0beta1 for my PHP 7.4 on Windows 10, configured it from scratch (using correct Xdebug 3 config values: and ). It is already supported in the most recent EAP #6 build: check this blog post for more info: Xdebug 3 will be fully supported in PhpStorm 2020.3 version only, which is currently in EAP stage (Early Access Program) and will be released in about 1 month time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |