1. Environment
To open the Postman console: Use the keyboard shortcut (CMD/CTRL + ALT + C) in the Postman app, or go to the application menu “View” “Show Postman Console”. The debugging power. Every network call sent with Postman is logged in the console in both its raw and pretty form, replacing all the variables that you’ve used in the request. In the console, you can inspect headers, certificates, requests, and responses. Postman Galaxy Is Now On Demand. This year's Postman Galaxy global API conference (held February 2-4, 2021) featured more than a hundred sessions on topics including API collaboration, development, testing, design, architecture, specifications, and more. And because we don’t want you to miss out, we’ve made some of the most popular Postman.
This blog post describes step by step tutorial to debug PHP applications with Visual Studio Code using XDebug extension on localhost.
Mine environment has:
- Wampserver 3.1.0 32 bit x86
- Apache 2.4.27 – PHP 5.6.31
- MySQL 5.7.19
- Visual Studio Code 1.20.1
- XDebug
2. Configure XDebug
Open the php.ini file (usually located at: c:wampbinapacheapache2.4.27binphp.ini) and add the following lines at the end of file:
Also, comment this line:
Xdebug Docker Phpstorm Postman
3. Install and configure XDebug add-on for your favorite web browser
For Chrome, you can download/install it from here.
For Firefox, you can download/install it from here.
Configure the extension to have proper IDE Key: PHPSTORM
4. Configure VS Code
– Install VS code plugins for PHP. For debugging PHP Debug plugin is required.
After installation, configure PHP intellisense on user level:
File > Preferences > Settings
and add the following section under user settings area:
Do not forget to change “php.validate.executablePath” to the proper path which you are using.
5. Debug
Xdebug Postman
– Run the xdebug listener in your browser from which you run the website:
– Open your PHP project in VS Code and click on 1st step (check the screenshot):
After click on settings button (2nd step) you should get a dropdown to pick a language for debug configuration. Pick PHP.
This confiig is saved per project under: your-site-root-folder/.vscode/launch.json.
Click save file and click on the debug button (3rd step).
After that, your debugger should be ready for incoming connections and you can put a breakpoint so you can debug.
After page reload (in your web browser), VS Code should break the execution at the breakpoint which you have previously set. Example:
Postman started out as an API development tool, but has developed more into, as they put it, an 'API Development Environment'.
An over-simplified description is it allows you to create and save requests to test your API. You can then save your requests as a *collection* and share or publish them for others to use.
It supports API calls for all request types, fine control over headers, common authentication methods, and long list of other features that could fill an article... but I wanted to write specifically about using Xdebug with Postman.
Xdebug Postman Vscode
How to trigger Xdebug when working with Postman
Recently, I was using Postman to troubleshoot an [API Platform](https://api-platform.com/) project and needed to trigger a Xdebug session in my IDE, [PhpStorm](https://www.jetbrains.com/phpstorm/).
Xdebug Postman Extension
Typically, I rely on a browser extension to trigger Xdebug, however Postman is its own application, so I could not rely on browser extensions.
Fortunately, there's an easy solution: Add `XDEBUG_SESSION_START=PHPSTORM` to the query string and PHPStorm will catch the debug session as it would if you were using a browser extension.
For example, if you are working on `http://localhost:8000/api/users`, simply append the URL with the query string mentioned above to initiate a debug session:
Now you can set breakpoints and debug as you would if you were working in a browser.