

Using these Composer directives allows you to use a single autoloader for locating and loading both libraries files pulled in as Composer dependencies and your own code and test. Of course, the most common way of autoloading files in this day is to use the `autoload` and `autoload-dev` keys of your `composer.json` file to setup autoloading for you. Here we can see that we’ve marked `lib/Doctrine/ORM` as a PSR-4 namespace root for the `Doctrine\ORM` and `tests/Doctrine/Tests` as a PSR-4 namespace root for `Doctrine\Tests`.Īdding this information is a little cumbersome and we’ve made attempts before to automate the process using the Detect PSR-0 Namespace Roots action (under the Code menu), but this has never been entirely successful and is getting less useful with the prevalence of the PSR-4 autoloading standard. It’s important when you’re marking folders as either Tests or Sources that you also tell PhpStorm which namespaces those directories contain, and you can do this by clicking on the Package Prefix icon under the directory listing in the right-hand pane: You can learn more about marking directories in the web help article. Resource Root – Contains resources that can be accessed relatively – like images, CSS files or javascript.Sources – Mark as a source of PHP autoloadable classes.Tests – Mark the directory as a source of PHPUnit tests.You can mark directories as sources or tests from the context menu in the project pane, or you can use the Directories section of the Preferences window. Telling PhpStorm where your namespaced files live will help when creating classes and tests (and navigating between them) and refactoring things. You can configure the PHP version you are targeting using the dropdown you’ll find under Preferences | Languages and Frameworks | PHP: Telling PhpStorm which version of PHP you’re targeting allows the inspections that power the IDE to let you know if you’re using things that are deprecated (or not available in your target version), and enables some features that are only available in later versions of PHP like the scalar parameter and return types.

When you’re using PhpStorm to develop efficiently, there is a few configuration setting that should be right to make the IDE is as helpful as possible. Configuring PhpStorm correctly is important to get the most out of your IDE, and PhpStorm 2017.2 has made it easier by allowing you to detect some of the settings from your `composer.json` file.
