Reputation: 3613
I have a task script that works perfectly fine if i run it by visiting the php file from my browsers. However, when i attempt to run it via Plesk Task Scheduler it fail with a fatal error unable to load the require()
file.
The require statement is a simple relative path:
require('../../../app.config.php');
the error is:
PHP Fatal error: require(): Failed opening required '../../../app.config.php'
I think this may be related to the include_path
but i don't know much about it so a bit lost on that one.
Any help would be great!
Upvotes: 2
Views: 206
Reputation: 3572
relative pathes resolved by current directory. Solutions: Get script directory and combine with the relative path, something like:
require(dirname(__FILE__).'/../../../app.config.php');
Upvotes: 1
Reputation: 108
You need to use absolute path. A different relative path may be produced if a script is called directly or the script is included in another script.
For example:
a.php is on path A/B/C the ../../ will result in in A/
b.php is on path A/B/C/D, if it inlcudes the a.php then the ../../ on a.php will result in A/B/.
Upvotes: 0