0

I'm working on a restful API in php. All is working on localhost, but when I try to put it on my server, I have these errors :

Warning: include_once(/path/to/api/simpletodo_api/Models/TodoItem.php) [function.include-once]: failed to open stream: No such file or directory in /homez.338/login/www/path/to/api/simpletodo_api/index.php on line 6

Warning: include_once() [function.include]: Failed opening '/path/to/api/simpletodo_api/Models/TodoItem.php' for inclusion (include_path='.:/usr/local/lib/php') in /homez.338/login/www/path/to/api/simpletodo_api/index.php on line 6

Here my include :

include_once 'Models/TodoItem.php';

index.php and the "Models" folder are in the same folder (in local and on my server).

I'm pretty sure it is a path error, but I can't find the right one.

Have you an idea of the path ?

carndacier
  • 960
  • 15
  • 38

1 Answers1

0

If your server is Linux-based and your localhost is on Windows, you may be running into file naming errors. File paths in Linux are case-sensitive. Just to be sure prepend the __DIR__ constant to your PHP path like so: include_once __DIR__ . 'Models/TodoItem.php';

  • I did `include_once __DIR__ . '/Models/TodoItem.php';`. Still working on my localhost, but again, on my server, I have this error : `include_once(__DIR__/Models/TodoItem.php) [function.include-once]: failed to open stream: No such file or directory [...] ` – carndacier Feb 13 '14 at 12:30
  • There is now a troubleshooting checklist for this frequent error here : stackoverflow.com/a/36577021/2873507 – Vic Seedoubleyew Apr 12 '16 at 17:04