Postman Xdebug



Requirements: You already need to configure PhpStorm with xdebug and php Here How to Do that: then when requesting from POSTMAN just add XDEBUGSESSIONSTART=PHPSTORM to the query string and PHPStorm will catch the debug session. Using Postman or your browser, send a request to the endpoint where you put the breakpoint (using the appropriate request method). Visual Studio should now be in debug mode, paused on the breakpoint. You can interact with it much like you would the debugger in your browser’s console. Try stepping through the code and stepping into methods.

  1. Postman Xdebug Vscode
  2. Xdebug Debug Postman
  3. Postman Xdebug 3
  4. Postman Xdebug
Forked from yannbertrand/using_xdebug_with_postman.md

XDEBUg is not dependent on a PHP framework whether it runs or not. Although the apache shouldn't start with '0o'. Xdebug.remoteautostart = 0o This is my XDEBUG. 这都 9102 年啦,如果还在疯狂 vardump print 的进行调试,那也太慢了吧。对于开发者而言,趁手的调试器必不可少。在 PHP 开发环境下,目前有两种流行的调试器: XdebugZend Debugger由于换了新电脑(捂脸),今.

Using Xdebug on Devilbox with PhpStorm and Postman
xdebug_devilbox_phpstorm_postman.md

commented Oct 3, 2019

Thanks a lot for this gist!! Especially the lines below where a blessing, could not find a better explanation elsewhere (my partner always says that i cannot find anything though) and it should have a more prominent place in the Devilbox docs:

Settings / Languages & Frameworks / PHP
Set CLI Interpreter by clicking on …
Add a new interpreter by clicking on + then choose From Docker, Vagr…
Tick Docker and add the Docker Server and then choose under Image name : devilbox/php-fpm:X.X-work…

I use Ubuntu

commented Oct 21, 2019

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Xdebug's built-in profiler allows you to find bottlenecks in your script and visualize those with an external tool such as KCacheGrind or WinCacheGrind.

Introduction #

Xdebug's Profiler is a powerful tool that gives you the ability to analyseyour PHP code and determine bottlenecks or generally see which parts of yourcode are slow and could use a speed boost. Since Xdebug 2.6, the profiler alsocollects information about how much memory is being used, and which functionsand methods increase memory usage.

The profiler in Xdebug outputsprofiling information in the form of a Cachegrind compatible file. This allowsyou to use the excellent KCacheGrindtool (Linux, KDE) to analyse your profiling data. If you are on Linuxyou can install KCacheGrind with your favourite package manager.

If you are on Windows, there are precompiled QCacheGrindbinaries available. (QCacheGrind is KCacheGrind without KDE bindings).

If you are on Mac OSX, there are instructionson how to build QCacheGrind too.

Users of Windows can alternatively useWinCacheGrind. Thefunctionality is different from KCacheGrind so the section that documents theuse of KCacheGrind on this page doesn't apply to this program. WinCacheGrindcurrently does not support the file and function compression for cachegrindfiles that Xdebug 2.3 introduces yet.

There is alsoan alternative profile information presentation tool calledxdebugtoolkit, a webbased front-end called Webgrind, and a Java based toolcalled XCallGraph.

In case you can not use KDE (or do not want to use KDE) the kcachegrindpackage also comes with a perl script 'ct_annotate' which produces ASCII outputfrom the profiler trace files.

Starting The Profiler #

Profiling is enabled by setting xdebug.mode to profile. Thisinstructs Xdebug to start writing profiling information into the dump directoryconfigured with thexdebug.output_dirdirective. The name of the generated file always starts with'cachegrind.out.' and ends with either the PID(process ID) of the PHP (or Apache) process or the crc32 hash of thedirectory containing the initially debugged script. Make sure you have enoughspace in your xdebug.output_dir as the amount of information generated by the profiler can beenormous for complex scripts, for example up to 500MB for a complex applicationlike eZ Publish.

You can also selectively enable the profiler by settingxdebug.start_with_request#trigger to trigger. You can then enablethe profiler by using an environment value, a GET/POST parameter, or COOKIEvariable of the name XDEBUG_SESSION. The FireFox and Chromeextensions that can be used to enable the step debugger (seeHTTP Debug Sessions) can also be usedwith this setting.

From Xdebug 2.6 onwards, Xdebug adds the HTTP headerX-Xdebug-Profile-Filename to a request that is being profiled.This header contains the name of the file that holds the profiling informationfor that request.

Analysing Profiles #

After a profile information file has been generated you can open it withKCacheGrind:

Once the file is opened you have plenty of information available in thedifferent panes of KCacheGrind. On the left side you find the 'Flat Profile'pane showing all functions in your script sorted by time spent in this function,and all its children.The second column 'Self' shows the time spent in this function (without itschildren), the third column 'Called' shows how often a specific function wascalled and the last column 'Function' shows the name of the function. Xdebugchanges internal PHP function names by prefixing the function name with'php::' and include files are handled in a special way too. Calls to include(and include_once, require and require_once) are followed by '::' and thefilename of the included file. In the screenshot on the left you can see thisfor 'include::/home/httpd/ez_34/v..' and an example of an internal PHPfunction is 'php::mysql_query'.The numbers in the first two columns can beeither percentages of the full running time of the script (like in theexample) or absolute time (1 unit is 1/1.000.000th of a second). You canswitch between the two modes with the button you see on the right.

The pane on the right contains an upper and lower pane. The upper oneshows information about which functions called the current selected function('eztemplatedesignresource->executecompiledtemplate in the screenshot).The lower pane shows information about the functions that the current selectedfunction called.

The 'Cost' column in the upper pane shows the time spent in the currentselected function while being called from the function in the list. The numbersin the Cost column added up will always be 100%. The 'Cost' column in the lowerpane shows the time spent while calling the function from the list. While addingthe numbers in this list up, you will most likely never reach 100% as theselected function itself will also takes time to execute.

The 'All Callers' and 'All Calls' tabs show not only the direct calls fromwhich the function was called respectively all directly madefunction calls but also function calls made more levels up and down.The upper pane in the screenshot on the left shows all functions calling thecurrent selected one, both directly and indirectly with other functionsinbetween them on the stack. The 'Distance' column shows how many functioncalls are between the listed and the current selected one (-1). If there aredifferent distances between two functions, it is shown as a range (for example'5-24'). The number in parentheses is the median distance. The lower pane issimilar except that it shows information on functions called from the currentselected one, again either direct or indirect.

Related Settings and Functions

  • stringxdebug.log =
  • integerxdebug.log_level = 7
  • stringxdebug.mode = develop
  • stringxdebug.output_dir = /tmp
  • integerxdebug.profiler_append = 0
  • stringxdebug.profiler_output_name = cachegrind.out.%p
  • stringxdebug.start_with_request = default
  • stringxdebug.trigger_value = '
  • xdebug_get_profiler_filename() : mixed
  • xdebug_info() : void

Settings

string xdebug.log = #

Configures Xdebug's log file.

Xdebug will log to this file all file creations issues, Step Debuggingconnection attempts, failures, and debug communication.

Enable this functionality by setting the value to a absolute path. Make surethat the system user that PHP runs at (such as www-data if you arerunning with Apache) can create and write to the file.

The file is opened in append-mode,and will therefore not be overwritten by default. There is no concurrencyprotection available.

The log file will include any attempt that Xdebugmakes to connect to an IDE:

It includes the opening time (2020-09-02 07:19:09.616195), theIP/Hostname and port Xdebug is trying to connect to(localhost:9003), and whether it succeeded (Connected toclient :-)). The number in brackets ([2693358]) is theProcess ID.

It includes:

[2693358]
process ID in brackets
2020-09-02 07:19:09.616195
opening time

For Step Debugging:

For Profiling:

For Function Trace:

All warnings and errors are described on the Description of errors page, withdetailed instructions on how to resolve the problem, if possible. All errors are always logged throughPHP's internal logging mechanism (configured with error_login php.ini). All warnings and errors also show up in thediagnostics log that you can view by calling xdebug_info().

Step Debugger Communication

The debugging log can also log the communication between Xdebug and an IDE.This communication is in XML, and starts with the <init XMLelement:

The fileuri attribute lists the entry point of yourapplication, which can be useful to compare to breakpoint_setcommands to see if path mappings are set-up correctly.

Beyond the <init element, you will find the configuration offeatures:

And continuation commands:

You can read about DBGP - A common debugger protocol specification at its dedicated documation page.

The xdebug.log_level setting controls how much information islogged.

Note: Many Linux distributions now use systemd, whichimplements private tmp directories. This means that when PHPis run through a web server or as PHP-FPM, the /tmp directory isprefixed with something akin to:

Postman

This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

integer xdebug.log_level = 7#

Configures which logging messages should be added to the log file.

The log file is configured with the xdebug.log setting.

The following levels are supported:

LevelNameExample
0CriticalsErrors in the configuration
1ErrorsConnection errors
3WarningsConnection warnings
5CommunicationProtocol messages
7InformationInformation while connecting
10DebugBreakpoint resolving information

Criticals, errors, and warnings always show up in thediagnostics log that you can view by calling xdebug_info().

Criticals and errors are additionally logged throughPHP's internal logging mechanism (configured with error_login php.ini).

This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

string xdebug.mode = develop#

This setting controls which Xdebug features are enabled.

This setting can only be set in php.ini orfiles like 99-xdebug.ini that are read when a PHP process starts(directly, or through php-fpm), but not in .htaccess and.user.ini files, which are read per-request.

The following values are accepted:

off
Nothing is enabled. Xdebug does no work besides checking whetherfunctionality is enabled. Use this setting if you want close to 0overhead.
develop
Enables Development Aids including the overloaded var_dump().
coverage
Enables Code Coverage Analysis to generate code coverage reports, mainly incombination withPHPUnit.
debug
Enables Step Debugging. This can be used to step through your code while itis running, and analyse values of variables.
gcstats
Enables Garbage Collection Statistics to collect statistics about PHP's GarbageCollection Mechanism.
profile
Enables Profiling, with which you can analyse performance bottleneckswith tools like KCacheGrind.
trace
Enables the Function Trace feature, which allows you record every functioncall, including arguments, variable assignment, and return value that is madeduring a request to a file.

You can enable multiple modes at the same time by comma separating theiridentifiers as value to xdebug.mode: xdebug.mode=develop,trace.

You can also set the mode by setting the XDEBUG_MODE environmentvariable on the command-line; this will take precedence over the xdebug.mode setting, but will no change the value of the xdebug.mode setting.

string xdebug.output_dir = /tmp#

The directory where Xdebug will write tracing, profiling, and garbagecollection statistics to. This directory needs to be writable for the systemuser with which PHP is running.

This setting can be changed in php.ini, .htaccess(and equivalent files), and within a PHP file with ini_set().

In some cases (when profiling, or whenxdebug.start_with_request=yes with tracing), Xdebugcreates the file before the script runs. In that case, changes made throughini_set() will not be taken into account.

This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

Postman Xdebug

integer xdebug.profiler_append = 0#

When this setting is set to 1, profiler files will not be overwritten whena new request would map to the same file (depending on the xdebug.profiler_output_name setting.Instead the file will be appended to with the new profile.

string xdebug.profiler_output_name = cachegrind.out.%p#

This setting determines the name of the file that is used to dumptraces into. The setting specifies the format with format specifiers, verysimilar to sprintf() and strftime(). There are several format specifiersthat can be used to format the file name.

See the xdebug.trace_output_name documentation for the supportedspecifiers.

Download zwift macbook pro. This setting can additionally be configured through theXDEBUG_CONFIGenvironment variable.

string xdebug.start_with_request = default#

A Function Trace, Garbage Collection Statistics, Profiling, or Step Debuggingcan be activated at the start of a PHP request. Whether this happens depends onthe value of this setting:

yes

The functionality starts when the PHP request starts, and before any PHPcode is run.

For example xdebug.mode=trace andxdebug.start_with_request=yes starts a Function Trace for thewhole request.

no

The functionality does not get activated when the request starts.

You can still start a Function Trace with xdebug_start_trace(), Step Debugging with xdebug_break(), or Garbage Collection Statistics with xdebug_start_gcstats().

trigger

The functionality only gets activated when a specific trigger is presentwhen the request starts.

The name of the trigger is XDEBUG_TRIGGER, and Xdebug checksfor its presence in either $_ENV (environment variable),$_GET or $_POST variable, or $_COOKIE(HTTP cookie name).

Postman Xdebug Vscode

There is also a legacy fallback to a functionality specific trigger name:XDEBUG_PROFILE (for Profiling), XDEBUG_TRACE(for a Function Trace), and XDEBUG_SESSION (forStep Debugging).

Debug session management for Step Debugging is alsoavailable through XDEBUG_SESSION_START.

With xdebug.trigger_value you can control which specific trigger value willactivate the trigger. If xdebug.trigger_value is set to an emptystring, any value will be accepted.

Postman
default

The default value depends on xdebug.mode:

  • debug: trigger
  • gcstats: no
  • profile: yes
  • trace: trigger

string xdebug.trigger_value = '#

This setting can be used when xdebug.start_with_request is set totrigger, which is the default for Step Debugging and Function Trace.

In trigger mode, Xdebug will only start itsfunctionality when the XDEBUG_TRIGGER is set in the environment,or when the XDEBUG_TRIGGER GET, POST, or COOKIE variable isset.

Java se 6 download mac sierra. The legacy names XDEBUG_SESSION (for Step Debugging),XDEBUG_PROFILE (for Profiling), and XDEBUG_TRACE(for Function Trace) can also be used instead of XDEBUG_TRIGGER.

Normally, Xdebug does not look at which value is actually used. If thissetting is set to a non-empty string, then Xdebug will only trigger if thevalue matches the value of this setting.

Xdebug Debug Postman

With the following settings:

Xdebug's profiler will only start when either the environment variableXDEBUG_TRIGGER is set to StartProfileForMe, the GETor POST variable XDEBUG_TRIGGER is set toStartProfileForMe, or when the cookie XDEBUG_TRIGGERhas the value StartProfileForMe.

Postman Xdebug 3

See also:

xdebug.start_with_request#trigger
For how the triggering mechanism works, and which environment and server variables Xdebug acts on.

Functions

Postman Xdebug

xdebug_get_profiler_filename() : mixed#

Returns the name of the file which is used to save profile information to, or false if the profiler is not active.

xdebug_info() : void#

This function returns an HTML page which shows diagnostic information. It is analogous to PHP's phpinfo() function.

The HTML output includes which mode is active, what the settings are, and diagnostic information in case there are problems with debugging connections, opening of files, etc.

Each warning and error in the diagnostics log also links through to the Description of errors documentation page.