I usually tinker with the framework source code, as in the case of Laravel to see how structures are made. I noticed something interesting in Laravel 4 in relation to Laravel 3 .
In Laravel 3 , you use, to mount directory paths, the constant DS
, which is a constant declared with DIRECTORY_SEPARATOR
value.
Example:
path('public') . DS . 'index.php';
In the Laravel 4 , I see codes like the following:
app_storage() . '/views';
I know that this constant DIRECTORY_SEPARATOR
is responsible for returning the separator character of directories according to the operating system that is being used.
I had this as important, but the Laravel 4 (which is a more current and more "inside" framework) of the php news) simply does not use DIRECTORY_SEPARATOR
.
Does anyone know if this has to do with the old versions of PHP? I mean, in some version should I care about DIRECTORY_SEPARATOR
and then, from a certain version, that's no longer important?
Is there really any difference in the way operating systems read directory separators (example: Ubuntu, Linux, MAC)?
I would like to know this, because I want to know if I can simply do this directly.
Example:
include_once __DIR__ . '/vendor/autoload.php';
Or you would have to do things to avoid the risk of conflicts in operating systems, as in the example below:
function my_path($path)
{
return str_replace(['\', '//'], DIRECTORY_SEPARATOR, $path);
}
include_once __DIR__ . my_path('/vendor/autoload.php');