Blackfire stubs in PHPStorm 2020.1
PHPStorm 2020.1 is out, with stubs of the BlackfireProbe internal class.
Blackfire supports PHP via a C extension. That extension exposes a
\BlackfireProbe class that implements all the low-level profiling methods. This class is what the blackfire/php-sdk library uses for low level operations.
But did you know that you can directly use the
\BlackfireProbe class as well? In fact, it does not require to install nor master the SDK, and it covers the most common use cases such as:
- Controlling the instrumentation;
- Adding timeline markers with
- Generating sub-profile queries.
With the 2020.1 release a few weeks ago, PHPStorm now provides full code completion on the internal
\BlackfireProbe class, which makes the developer experience a lot smoother.
Furthermore, most of the methods exposed by
\BlackfireProbe stay inert, unless a profile is being requested. Putting it another way, you can add as many timeline markers as you want, and/or instrument specific parts of your application without overhead! At least, PHPStorm now knows about it 😊.
To make sure you get code completion, check that
blackfireextension is enabled in PHPStorm settings (Languages & Frameworks / PHP / PHP Runtime):
Oh, and one more thing ! VisualStudio Code uses PHPStorm stubs for its own code completion. This means that if you are a VS Code user, enjoy as well!