I'm writing in PHP for an OpenShift app and am stumped by a fatal error when I try to require another PHP script. I've tried numerous permutations of filepath, but none of them resolve the problem.
The PHP file appears to exist: I can SSH into my app and navigate to it at /var/lib/openshift/5357ba345973cac7c400021d/app-root/repo/lib/dothis.php
My current PHP code:
require_once ($_ENV['OPENSHIFT_REPO_DIR'] . 'lib/dothis.php');
Previous unsuccessful attempts:
1 set_include_path(get_include_path() . PATH_SEPARATOR . $_ENV['OPENSHIFT_REPO_DIR']);
require_once ('lib/dothis.php');
2 require_once ($_SERVER['DOCUMENT_ROOT'] . '/lib/dothis.php');
3 include ($_SERVER['DOCUMENT_ROOT'] . '/lib/dothis.php');
4 require ($_SERVER['DOCUMENT_ROOT'] . 'lib/dothis.php');
5 require (realpath(dirname(__FILE__)) . '/lib/dothis.php');
6 require (dirname(__FILE__) . '/lib/dothis.php');
For my current php code, the rhc tail
log gives this:
[Fri Apr 25 12:41:22 2014] [error] [client 127.3.140.1] PHP Fatal error: require_once(): Failed opening required '/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/lib/dothis.php' include_path='.:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/lib:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/libs:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/libraries:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/src:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/vendor:/var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/vendors:/var/lib/openshift/5357ba345973cac7c400021d/php/phplib/pear/pear/php:/usr/share/pear') in /var/lib/openshift/5357ba345973cac7c400021d/app-root/runtime/repo/process.php on line 221
dirname(__FILE__)
and adjust that path until you get what you need. – Krytenrequire 'lib/dothis.php';
? – Reeno