Working with composer.json in PhpStorm
What makes PHP great is the community that is building frameworks, libraries and nice tools. And more. This awesome community brought us Composer, a dependency manager for PHP which lets us install and update packages from Packagist.org and makes it easy to package up our own projects and make them available to the world.
That awesome community just extended PhpStorm’s support for Composer. Next to the UI for managing dependencies and completion for Composer’s command line tool that comes with our IDE, Piotr Śliwa‘s Composer.json plugin for PhpStorm adds completion and inspections for working with the composer.json file directly. Let’s see!
Installing the plugin
First things first, of course. We’ll have to install the Composer.json plugin for PhpStorm. Open the settings (Ctrl+Alt+S or CMD+, on Mac OS X) and click Plugins. In the pane that opens, click Browse repositories… and search for PHP composer.json support. The green Install plugin button will download and install the plugin into our IDE.
A quick restart of the IDE, and we’re good to go!
Let’s add a composer.json file to our project. When we start adding properties, the plugin provides completion (Ctrl+Space / CMD+Space) for all property names known in the composer.json schema, including a description of the property.
Not only properties are completed. For every property, the plugin knows what the possible values are and provides the necessary suggestions.
There’s also completion for dependencies and their versions, which are queried against Packagist.org. Start typing and press Tab to have the plugin complete the package name and jump into the version specification.
Inspections and quick-fixes for composer.json files
Many other nice little gems are available when working on the composer.json file. For example when adding a property that is not allowed according to the specs, the plugin will tell us and provide a quick-fix (Alt+Enter) to remove the erroneous entry.
The plugin also checks if referenced files exist and if not, provides a quick-fix to create it for us. This comes in very handy when working on the bin or autoload properties in composer.json.
Feel free to post feature requests for the plugin on GitHub. And of course all your comments and suggestions for PhpStorm are welcome through the issue tracker, in the comments below, or on our forums!
Develop with pleasure!
– JetBrains PhpStorm Team
Subscribe to Blog updates
Thanks, we've got you!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…