Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3.2 |
Hello,
I found bug on Windows when using PSR4 base service discovery.
When I've got in app/config/services.yml
:
services:
_defaults:
autowire: true
autoconfigure: true
AppBundle\:
resource: ../../src/AppBundle/**/*Controller.php
All controllers (and not only controllers) are not discovered because of backslashes. This bug is only reproducible on Windows so all tests pass.
I've found little tricky solution to change lines 136-140 in vendor/symfony/symfony/src/Symfony/Component/Config/Resource/GlobResource.php
from:
foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
if (preg_match($regex, substr($path, $prefixLen)) && $info->isFile()) {
yield $path => $info;
}
}
To:
foreach ($finder->followLinks()->sortByName()->in($this->prefix) as $path => $info) {
$normalizedPath = str_replace(array('/', '\\'), '/', $path); // normalize directory separator to UNIX slashes
if (preg_match($regex, substr($normalizedPath, $prefixLen)) && $info->isFile()) {
yield $path => $info;
}
}