phpautocompletephpstormrelative-pathcode-hinting

Tell PhpStorm to start looking for files in a specific path


My Project structure looks something like this:

enter image description here

In my index.php I include the content from abilities.php with

<?php
    if (isset($_GET['site'])) {
        switch ($_GET['site']) {
            ...
            case 'abilities':
                include("./content/abilities.php");
                break;
            ...
        }
    }
?>

In abilities.php I include my Class Ability.php via

require_once ("./model/Ability.php");

which works perfect in the browser, but PhpStorm says it cannot find the class:

enter image description here

that's most likely because it searches for a model directory with the Class Ability.php in the content directory which isn't there.

So my question is how can I tell PhpStorm to start looking for files as if my abilities.php would be in the root directory like index.php?

Like setting a alternate path for abilities.php to start looking for files or something similar.


Solution

  • Have you configured you project structure in PHPStorm? Find Project Settings, and you can check if one is or mark a directory as 'sources'. That would the the parent directory of those shown in the screenshot in your case.

    enter image description here

    The screenshot is for a Java project but you can tell IDEA the same way for PHP projects where to look for source files.