I have a PHP script that includes another file in an adjacent directory.
Example code:
include("../lib/file.php");
The code works fine when you access the page running it from a browser but fails (on the mentioned include() line) if I run it from a terminal or cron.
I get a warning that says “No such file or directory in /path/to/file.php” and as a result the class I try to call from that file doesn’t exist, which leads to a fatal error.
What would cause this to work from a browser but fail from terminal.
Always always always use absolute paths with include: