You can can change this to a location of your choice, but remember it must have write permissions for the user account under which the PHP script is run. Xdebug stores the profiling output in the directory specified by xdebug.profiler_output_dir. xdebug.profiler_output_name is the filename of the profiler log (the %t specifier appends a timestamp to the filename see the documentation for a full list of specifiers). Profiling is disabled by default in Xdebug, so xdebug.profiler_enable is used to enable it. Xdebug.profiler_output_name = xdebug.out.%t To start profiling your applications, add the following settings to php.ini: xdebug.profiler_enable = 1 Xdebug can also be used as a profiling tool for PHP. The output can be analyzed to understand where the bottlenecks are. Profiling tools record important details like the time it takes for statements and functions to execute, the number of times they are called, and so on. Profiling is the first step when optimizing any application. You can watch their values change as you step through through the statements. It will show the values of local variables and super global variables like $_COOKIE, $_GET, $_POST and $_SERVER. While running, the state of the variables in the current scope are shown in the variables window. Alternatively, go to Window > Debugging > Breakpoints which will list all breakpoints in your program and you can select/deselect only those you needed. They can be removed by clicking on them again. You can add breakpoints by clicking the line number in the editor’s margin and then pause execution on them. Step out – Step out of the current function.Step into – Step into the function (for non-built-in functions).Step over – Step over the currently executing line.There are some other useful actions in the debugging toolbar. To trigger the debugger you must pass XDEBUG_SESSION_START as a request parameter (GET/POST) or XDEBUG_SESSION as a cookie parameter. Notice in the brower’s URL bar the XDEBUG_SESSION_START parameter. From there you can continue to the next break point using the continue button. Otherwise, it will run until it encounters the first breakpoint. It will open up the application in a browser, and PHP’s execution will pause at the first line of the file if you have enabled the “Stop at first line” option in the Options window. With your source file open, press the Debug button in the toolbar to start debugging. Now you’ll be able to run the debugger by clicking Debug in the tools tab. Enter the debugging port given in php.ini and a Session ID which you’ll need to pass with the requests you want to debug. Open the options window (Tools > Options) and go to the debugging tab for the PHP section. You can easily configure Netbeans to act as an Xdebug client. Then you can inspect the variables’ values in that scope to get better insight into what PHP is doing. Xdebug overcomes this by letting you pause your application’s execution where ever you want. But the problem with this approach is that you have to modify the code for debugging you must remember every place you added output statements and remove them after debugging is finished. More often than not it’s tempting to use the var_dump() and exit/ die() combination for debugging. You can take the output of phpinfo() or php –i and paste it in the text box and have the wizard analyze your server’s configuration and instruct you on how to compile Xdebug for your machine. The Xdebug website provides a simple wizard to guide you through installation. There are other installation options as well. When you use Xdebug, it’s important to make sure you are not using any other Zend extensions since they may conflict with Xdebug. xdebug.remote_port is the port on which the client listens for a connection from Xdebug (9000 is the default value). xdebug.remote_host is the name or the IP address of your system (here I’ve specified localhost because I’m working all on the same machine, but the value can be an IP Address or a DNS hostname if you need to specify something different for your setup). The xdebug.remote_enable value toggles whether the extension is active or not. Zend_extension specifies the path to the Xdebug module. The entries for Xdebug in my php.ini look like this: If you are using a package based installation on a platform such as Ubuntu, you can install it through your package manager with a command like apt-get install php5-xdebug. If you are using XAMPP or MAMP, Xdebug comes preinstalled you just need to enable it in your php.ini.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |