Search code examples
phpstorm

PhpStorm tells me: "Namespace name doesn't match PSR 0/PSR 4 project structure"


I'm using Laravel 5.0 and everything works fine.

However, I keep getting these warning messages. I have looked at the JetBrains docs, but I remain a bit foggy what to do about it.

Essentially, I am concerned that if I allow PhpStorm to automatically run "Detect PSR0 Namespace Roots" then it could break my code / project.

Not sure what is going on, what should I do?


Solution

  • If you use composer the more recent answer to synchronize with composer is a better option.


    PSR-4 namespace roots can specify a prefix which can be configured.

    Here is the process:

    1. Find the root of your namespace e.g src.
    2. right click Mark Directory as Sources Root.
    3. Menu -> File -> Settings -> Directories.
    4. Click the pencil icon or p^ next to your Sources Root.
    5. Enter the namespace prefix.

    See PHPStorm configuring PHP namespaces