Amit Amit - 8 months ago 47
Linux Question

Having a folder path issue migrating to a new PHP server. folder/../folder2

I installed a Vagrant box called Homestead, and was trying to run my app.

Locally, I use PHP 7.0.9 on a windows machine

The box uses PHP 7.0.8 on a linux (Ubuntu) machine

The problem:

I am using Codeigniter, with HMVC, which does this:


This translates into
on my machine, but in the vagrant box stays like that.

Is there a setting I can change for it to work in the Vagrant box as well?


The solution:

  • Easy: Create a folder application/controllers which has a file, so git will save it
  • Hard (and a bad solution): In the CI core, around line 400, add the following code: (to resolve the path and remove ../)

function resolve_path($path) {
    $stack = [];
    foreach (explode('/', $path) as $segment)
        if ($segment == "..")
            array_pop($stack); else
            $stack[] = $segment;
    return implode('/', $stack);

$controller_path = resolve_path(APPPATH . 'controllers/' . $RTR->directory . $class . '.php');