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

SYSDIR #25

Closed
exbit opened this issue Mar 16, 2016 · 7 comments
Closed

SYSDIR #25

exbit opened this issue Mar 16, 2016 · 7 comments

Comments

@exbit
Copy link

exbit commented Mar 16, 2016

windows OS
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
var_dump(SYSDIR);
string(0) ""

Fix:
define('SYSDIR', trim(strrchr(trim(str_replace('', '/', BASEPATH), '/'), '/'), '/'));

@narfbg
Copy link
Collaborator

narfbg commented Mar 16, 2016

This constant is useless, I'm voting to remove it.

@lonnieezell
Copy link
Member

I agree with @narfbg. In the 10 or so years that I've been working with CI, I don't think I've ever found a need for that. And it's handled by the $systemFolder variable if you want to change it.

@lonnieezell
Copy link
Member

It's been removed.

@sv3tli0
Copy link
Contributor

sv3tli0 commented Mar 17, 2016

I think that the same remove can be made and on other constants. Path Class is a lot better choice to register and handle paths..

@lonnieezell
Copy link
Member

I don't see a path class being beneficial here. The way CI has always done it is simple, by creating constants for paths that are constant. They're available sitewide. And they use less resources than a class would.

@sv3tli0
Copy link
Contributor

sv3tli0 commented Mar 17, 2016

I can't give any 100% important reason to have class instead of just constants.
But at least what I understand from OOP developement, hard coded constants are not really beautiful solution.

Instead all over the code to check if file_exists(SOMEPATH. 'folder/file') and to require it..
You can just use 1 already loaded resource to get the existing path of the file which you need and if it doesn't you will get proper exception/error (not existing no permissions and etc)..

Of course this has something to do and with the Loaders..

@lonnieezell
Copy link
Member

Like anything else, OOP design can be taken to extremes it really doesn't need to be.

In this case, you're right, that's more to do with a loader, or some other class. But if you go the route of creating OOP wrappers for all of PHP's non-OOP functions, things get a little crazy. :) In this case, your example, while a valid function (not necessarily requiring an entire class, but could be ...) would replace if file_exists calls with try/catch blocks throughout the code, which can harm performance, and isn't anymore beautiful when all you want to do is see if file exists....

I'm not saying your class idea doesn't have certain appeals for different situations, but for this one, I think it's overkill and complicates things instead of simplifies them.

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