Structure of my files is like so:
config.php
script
|--myscript.php
myscript.php
<?php
require '../config.php';
?>
When executing php /path/to/myscript.php I get Warning: require(../config.php): failed to open stream: No such file or directory.
Whats the reason?
That’s because your current working directory is the one you call your command at, not the one your script is located in.
Use
instead.
__DIR__is a const that points to the directory current file is located in.