-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Problem with SourceCodeExtension.php\getControllerRelativePath function in Windows #14239
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@cktdesign thanks for reporting this issue. I'll take care of it right away! By the way, since this is a Symfony Demo issue, next titme it'd be better if you report it directly at https://github.com/symfony/symfony-demo/issues Thanks! |
@cktdesign the proposed fix is ready at symfony/demo#25 If you agree, please close this issue and let's move the discussion to the |
javiereguiluz
added a commit
to symfony/demo
that referenced
this issue
Apr 7, 2015
…iereguiluz) This PR was squashed before being merged into the master branch (closes #25). Discussion ---------- Use DIRECTORY_SEPARATOR constant to avoid Windows issues This PR fixes the issue reported at symfony/symfony#14239 Commits ------- 622a9d0 Use DIRECTORY_SEPARATOR constant to avoid Windows issues
sayjun0505
added a commit
to sayjun0505/sym_proj
that referenced
this issue
Apr 16, 2023
…iereguiluz) This PR was squashed before being merged into the master branch (closes #25). Discussion ---------- Use DIRECTORY_SEPARATOR constant to avoid Windows issues This PR fixes the issue reported at symfony/symfony#14239 Commits ------- 622a9d0 Use DIRECTORY_SEPARATOR constant to avoid Windows issues
spider-yamet
added a commit
to spider-yamet/sym_proj
that referenced
this issue
Apr 16, 2023
…iereguiluz) This PR was squashed before being merged into the master branch (closes #25). Discussion ---------- Use DIRECTORY_SEPARATOR constant to avoid Windows issues This PR fixes the issue reported at symfony/symfony#14239 Commits ------- 622a9d0 Use DIRECTORY_SEPARATOR constant to avoid Windows issues
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To recreate the problem just install symfony demo in windows and browse it. The problem happens because windows use a different directory separator than linux. Github escapes the windows directory separator so instead of it i will use the symbol " | " in the following sentences.
Original function uses the following code
$pathParts = explode('/src/', $absolutePath);
To fix it you could use
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$pathParts = explode('||src||', $absolutePath);
$relativePath = 'src||' . $pathParts[1];
} else {
$pathParts = explode('/src/', $absolutePath);
$relativePath = 'src/' . $pathParts[1];
}
or
if (DIRECTORY_SEPARATOR == '/') {
$pathParts = explode('/src/', $absolutePath);
$relativePath = 'src/' . $pathParts[1];
} else if (DIRECTORY_SEPARATOR == '||') {
$pathParts = explode('||src||', $absolutePath);
$relativePath = 'src||' . $pathParts[1];
}
The text was updated successfully, but these errors were encountered: