0

I'm working on a Laravel 4 based project. I recently migrated to Laravel's Forge, where suddenly all of my relative URI based function calls to "copy" and "md5_file" suddenly stopped working. The solution I found on my own was to replace them all with absolute function calls, which has worked so far. However:

  • I have no idea what/why happened
  • I don't have any way of predicting what other changes may be required.

If it helps, my previous stack was PHP 5.4.9-4ubuntu2.4 via apache and forge uses PHP 5.5.15-1+deb.sury.org~trusty+1 via nginx.

So I don't know if this is a PHP thing, Apache vs nginx thing, or Laravel Forge thing.

Basically, the following code:

if (file_exists($file_uri) && is_readable($file_uri))
{
    return md5_file($file_uri);
}
return null;

produced the following exception:

md5_file($file_uri): failed to open stream: No such file or directory

BUT, that exception is only occuring on my Forge/NginX/PHP server with non-absolute URIs.

Uyghur Lives Matter
  • 18,820
  • 42
  • 108
  • 144
Michola Ultra
  • 145
  • 1
  • 13
  • In PHP paths are relative to the file being executed, or the current directory the script is being executed from, not the file the enacting script is located. You may want to find out the environmental changes, relative paths should still work. – Flosculus Aug 11 '14 at 16:21
  • Thanks for responding Flosculus, I realized that I forgot a critical piece of information for this. I've edited my original question to include a code snippet. – Michola Ultra Aug 12 '14 at 21:20
  • Give us some paths you are using. Then run `getcwd` and give us the result. – Flosculus Aug 13 '14 at 08:08
  • On the non-forge servers with relative URIs, they would have been 'app/storage/photos/e8/f1/2344.png' (for example) which would fail on forge. The absolute URIs that worked on both would have been like '/var/www/website.com/laravel/app/storage/photos/e8/f1/2344.png' before forge and '/home/forge/website.com/app/storage/photos/e8/f1/2344.png' on forge. In both cases, file_exists returned true when md5_file said file does not exist only on forge. – Michola Ultra Aug 13 '14 at 21:51
  • When a file actually did not exist, both forge and pre-forge reported file_exists to be false. – Michola Ultra Aug 13 '14 at 21:52
  • Run `getcwd`, the paths should be relative to that path. – Flosculus Aug 14 '14 at 07:57

0 Answers0