-
-
Notifications
You must be signed in to change notification settings - Fork 437
Closed
Description
Steps to reproduce:
- Create a symfony project and leave App\ as a psr-4 prefix
- Create a controller with make:controller App\MyController
Expected behaviour:
- Generated class named MyController
- Generated namespace App\Controller\App\MyController
- Generated file src/Controller/App/MyController.php
Actual result:
- Generated class named MyController
- Generated namespace App\Controller\App\MyController
- Generated file src/Controller/MyController.php
This is because when generating the file path, the psr-4 prefix is replaced in all of the path string like so (Symfony\Bundle\MakerBundle\Util\AutoloaderUtil::getPathForFutureClass()):
str_replace($prefix, '', $className)
If at any point in your directory structure, a directory is named exactly as your psr-4 prefix, it will be removed from the file path.
A simple fix would be to only remove the prefix at the begining of the string. Suggested implementation would be:
substr($className, strlen($prefix))
Metadata
Metadata
Assignees
Labels
No labels