Skip to content

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

Closed
ghost opened this issue Apr 6, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Apr 6, 2015

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];
}

@javiereguiluz
Copy link
Member

@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!

@javiereguiluz
Copy link
Member

@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 symfony-demo repository. Thanks.

@fabpot fabpot closed this as completed Apr 7, 2015
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants