Features Releases

HTTP Client Enhancements

We continue improving the editor-based HTTP client, and PhpStorm 2018.2 brings several useful enhancements to it: you can now use environment variables inside the request body, apply code formatting to POST request bodies, and enjoy built-in Unicode support.

Let’s take a closer look at these new features.

Support for environment variables in the request body

Environment variables let you parameterize certain parts of your request and substitute them with actual values when a request is executed. Previously, you could use variables for specifying the request’s host, port, and path, query parameter or value, and header value.

In PhpStorm 2018.2, you can use variables for providing arbitrary values within the POST request body, too.

The idea remains the same: declare your variables in an env file, and use the variables’ placeholders enclosed between double curly braces either directly inside an HTTP file or in the external files that you’ve included as the request body.

When you execute the request, PhpStorm will prompt you to choose the environment holding the desired variable’s value:

vars_in_body

Formatting of POST request body

Another improvement you’ll notice when working with POST requests in PhpStorm 2018.2 is the ability to format the request’s body.

To use it, simply invoke the Code | Reformat code action.

POST Body reformat

The request’s body will be formatted in accordance with its Content-Type ; if necessary, you can customize the code style for the corresponding language (for example, JSON or XML) under Preferences | Editor | Code Style.

Please note that formatting HTTP requests that contain variables in the request body is currently not supported. To format such a request, press Alt+Enter and choose Edit JSON/XML fragment. The fragment will open in a separate editor tab, from where you can format is as usual:

POST Body reformat

Decoding Unicode entities and character escapes in JSON replies

PhpStorm 2018.2. introduces the long-awaited support for Unicode symbols and character escape sequences in the HTTP response body.

rest_encoding-2

With this support in place, you can inspect your responses in a natural manner, without looking into the characters table to find out what these magical letters actually translate to.

Your JetBrains PhpStorm Team
The Drive to Develop

image description