Skip to content
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

Issue in framework/src/Illuminate/Foundation/helpers.php #8913

Closed
Ermac25 opened this issue May 28, 2015 · 9 comments
Closed

Issue in framework/src/Illuminate/Foundation/helpers.php #8913

Ermac25 opened this issue May 28, 2015 · 9 comments

Comments

@Ermac25
Copy link
Contributor

Ermac25 commented May 28, 2015

public_path() , database_path() , config_path() , app_path()

fail to work correcly on widows

public_path() returns example : c:\www\project\public as c:\www\project\public/

as you can see here

https://github.com/laravel/framework/compare/5.0...Ermac25:Ermac25-patch-1?expand=1

using DIRECTORY_SEPARATOR solves the issue

@GrahamCampbell
Copy link
Member

adding '/' as a string assumes a linux eviroment

No it doesn't. PHP converts it internally before doing the low level operations.

@Ermac25
Copy link
Contributor Author

Ermac25 commented May 28, 2015

Really? because public_path() on widows returns
in case off c:\www\lamp\project\public
it returns c:\www\lamp\project\public/

so why the / if it's already corrected?

i'll edit the issue in any case

@Garbee
Copy link
Contributor

Garbee commented May 28, 2015

This is an issue, but it is a BC breaking change. So should be done at the next major release whenever that happens.

@nicholasruunu
Copy link
Contributor

The issue is with consistency and parsing of paths.

public_path uses / while path.public uses DIRECTORY_SEPARATOR:

https://github.com/laravel/framework/blob/5.0/src/Illuminate/Foundation/Application.php#L338

return app()->make('path.public').($path ? '/'.$path : $path);

Not a huge deal but something to be considered. Possible BC break for windows users who have parsed paths.

@GrahamCampbell
Copy link
Member

it returns c:\www\lamp\project\public/

Yes, that's fine. Under the hood, php will make the correct low level calls when you actually use the filesystem.

@nicholasruunu
Copy link
Contributor

@GrahamCampbell Feels like you're dodging the actual issue here. Paths can be saved to db/returned by API and be used in other languages too. And as I stated earlier, inconsistency when parsing strings is still an issue, just explode(DIRECTORY_SEPARATOR, $path) would not work as expected on windows.

@GrahamCampbell
Copy link
Member

That doesn't seem to be an issue as far as I'm concerned. You need a more robust solution if you want to do that. You may want to write yourself a simple normalize path function or something.

@nicholasruunu
Copy link
Contributor

Yeah, you're right, you should write a normalize function for exploding separators using public_path(). It actually should be inconsistent for no apparent reason.

@Garbee
Copy link
Contributor

Garbee commented May 28, 2015

This is the framework producing inconsistent output. Something Taylor prides himself on it doing. Consistency and reliability are major things Laravel offers developers, and this fails in that regard.

It is a major issue, and in fact breaks the ability to simply hand off the paths generated to another method since you then would need to wrap it in your own function to normalize it yourself.

Either way though, it is an existing issue that could be relied upon in user-land code. Fixing it could introduce a BC break. So it should not be addressed in the 5.x line but taken care of in 6.0 whenever that happens to land.

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

4 participants