![]() ![]() If you try to debug your application now, using the browser extension you’ll send a flag to the server and it’ll run Xdebug, tehn it’ll try to communicate with the address you configured in xdebug.remote_host, but it won’t make it since we configured it as localhost. Now, you’ll need a browser extension that helps you trigger the debugger (I use Xdebug helper for Chrome). Name: Anything meaningful for you Host: Server IP address Port: The port used by Apache Debugger: Select Xdebugīelow, (I’m assuming you have the project code in your machine, we said you can’t run it locally, but you’ll still need the code) map the folders (paths) of the code in your local machine and the server. Go to Preferences -> Languages & frameworks -> PHP -> Servers Go to Preferences -> Languages & frameworks -> PHP -> Debug Xdebug.remote_log=/var/log/apache2/xdebug.logĪs I said, I’m using PHPStorm, but any IDE configuration should be similar. conf file inside your conf.d folder, it depends on the server’s OS) xdebug.remote_enable=1 The Xdebug configuration goes in the php.ini file (or in a specific. SSH to the remote server and install Xdebug sudo apt-get install php5-xdebug (Debian based servers) Configure Xdebug An IDE in your machine (I use PHPStorm).I won’t go trough the basics on how to use the debugger or about the magic behind the debug session (plenty of blog posts on this already). So you’re back already, huh? I know why, because I too spent hours searching for documentation, blog posts, forums and some helped, but I couldn’t find a single one with all the information, so since I already did the research, here is all the info to save you and everyone else the trouble. Right? Sure, go do it and I’ll wait here while you figure it out. Okay so you know what to do, right? Just install Xdebug in the server, set up your IDE and let the magic happen. You’ve got SSH access to the testing server.You need to check an issue in a PHP web application.Who in their right mind would want to develop using a remote server when you have Docker and all that other useful stuff? But, trust me, if you come into this unfortunate situation, you’ll be sending me all your love (or a beer, which is almost the same thing). In it, I take time to walk through PHPStorm and show hands on how to Debug using PHPStorm, Lando, and XDebug.I know what you’re thinking. Obviously your code has to execute to pause (which itself can be a challenge) but you aren’t limited to “just the thing you print.” It shows you all the things going on. Enter Debugging.ĭebugging lets you get a much more in depth look at everything that is going on at the moment of your breakpoint. In D8/D9, NOT everything is a hook and aside from that, there’s a lot of ambiguous stuff going on outside the scope of the method you’re in (thanks to Symfony) that you may not know to try and print out with Devel. In a Drupal context, in the old days (D6/D7) a debugger wasn’t critical because basically all custom PHP as written in hooks (which essentially always execute, and have fairly simple data models). ![]() Typical debugging facilities include the ability to run or halt the target program at specific points, display the contents of memory, CPU registers or storage devices (such as disk drives), and modify memory or register contents in order to enter selected test data that might be a cause of faulty program execution. The main use of a debugger is to run the target program under controlled conditions that permit the programmer to track its operations in progress and monitor changes in computer resources (most often memory areas used by the target program or the computer's operating system) that may indicate malfunctioning code. ![]() Using a DebuggerĪnother pretty significant part of using an IDE is the ability to tie in a Debugger (like XDebug). The IDE is going to tell you that immediately so as you write the code you can see it and go… “OH MAYBE I SHOULDN’T USE THIS METHOD.” Sublime is going to let you go blissfully along and not warn you that it’s a problem. Notice how in the two screenshots the getStorage method is scratched out in PHPStorm (but not in Sublime Text)? This is because it’s a deprecated method. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |