- 1. Prerequisites
- 2. Taking advantage of SensioLabsInsight integration in PhpStorm
1.1. SensioLabsInsight plugin installation in PhpStorm
SensioLabsInsight plugin can be easily installed in PhpStorm's Settings (Preferences) | Plugins | Browse repositories... Select SensioLabsInsight and click Install plugin:
After the plugin is installed, restart your IDE. SensioLabsInsight will appear in the list of installed plugins:
1.2. Creating SensioLabsInsight account and analyzing your first project
Please refer to Getting Started with SensioLabsInsight tutorial to create your account and analyze your first project.
Once your account is created, you will find your SensioLabsInsight User UUID and API token, on your Account > API/SDK page. These details are required to connect PhpStorm to your SensioLabsInsight account (see 1.3 Connecting PhpStorm to your SensioLabsInsight account).
Once you have analyzed your first project, you will be able to view the results in PhpStorm.
1.3. Connecting PhpStorm to your SensioLabsInsight account
In order to connect PhpStorm with installed SensioLabsInsight plugin to your active SensioLabsInsight account, provide your User UUID and API token in PhpStorm's Settings (Preferences) | SensioLabsInsight. Click Open SensioLabsInsight's dashboard to open the dashboard, copy User UUID (user) and API token (password), and then paste these to PhpStorm settings.
You can save auth settings as default API settings to be used in all other projects.
2. Taking advantage of SensioLabsInsight integration in PhpStorm
2.1. Creating a PhpStorm project connected to SensioLabsInsight
In case you would like to enable SensioLabsInsight integration for existing project, just make sure that it's pointing to the same VCS repository you've used in the SensioLabsInsight web interface.
To check your current VCS root configuration for your project, go to Settings (Preferences) | Version Control:
Assuming that you've configured the connection to your SensioLabsInsight account in the previous step, the plugin will configure the association with specific projects based on Git remote URL. You can check or select a project manually in Settings (Preferences) | SensioLabsInsight | Select project:
If you want to create a new project, just proceed as usual. Check out the PhpStorm Quick Start guide to learn more about creating projects. If the project is created from repository, it'll be automatically associated with relevant SensioLabsInsight project (based on Git remote URL); otherwise you'll need to select it in settings as described above.
2.2. Exploring SensioLabsInsight analysis results in PhpStorm
After the integration between SensioLabsInsight and PhpStorm is configured, the latest report from SensioLabsInsight service is fetched by PhpStorm. All rule violations are shown in the left gutter of the editor window:
Click the orange icon to get a more complete annotation for the rule violation, with an option to navigate directly to the full SensioLabsInsight report:
2.3. Running inspections in PhpStorm
SensioLabsInsight inspections are closely integrated with PhpStorm's native inspections, meaning that you can bring up the results of all inspections in PhpStorm with the Code | Inspect code action. Some specific SensioLabsInsight inspection results can be also retrieved with Code | Run inspection by Name...:
One more convenient way to run SensioLabsInsight-based inspections is from the SensioLabsInsight panel at the bottom of PhpStorm screen:
Clicking this panel will show all SensioLabsInsight-related actions. Select Run code inspections:
The results will be shown straight away in the tool window:
From here you can navigate to the source code, or explore more information in the full report on the SensioLabsInsight website.
2.4. Updating SensioLabsInsight report in PhpStorm
SensioLabsInsight is all about improving your analysis results continuously. This means that updating your report is an important step. To fetch the latest report from the SensioLabsInsight server, just use Sync. with latest analysis on SensioLabsInsight action in the SensioLabsInsight panel:
For maximum performance, make sure to configure your SensioLabsInsight project to be re-analyzed on every commit. Synchronizing with server, PhpStorm plugin will automatically get analysis report on current commit hash or corresponding branch.
2.5. Navigating to SensioLabsInsight dashboard
There are many ways to navigate to the SensioLabsInsight dashboard from the application: from the inspection icon in the editor gutter, the inspection result tool window, or the SensioLabsInsight panel at the bottom of PhpStorm screen where all the current stats and options are shown:
Give SensioLabsInsight a try right now.