How to get the WHMCS root directory

I have made a simple WHMCS add on that uses the hook function in WHMCS. It works fine on my installation if I use require_once (ROOTDIR.'/modules/addons/module_name/modulefunction.php') because I use a sub domain for my WHMCS. But i tested it on another installation which does not use a sub domain and not it does not work, because the WHMCS directory is not included in the name.

Is there any way for me to get the name of the directory or just go from the hooks folder (includes/hooks/my_hook.php) backwards to the addons directory.

I tried using require_once '../../../modules/addons/module_name/modulefunction.php'; but it just says it cannot find the file.


Fatal error: require_once(): Failed opening required '../../../modules/addons/module_name/modulefunction.php' (include_path='/home/me/public_html/hosting/vendor/phpseclib/phpseclib/phpseclib:.:/usr/lib/php:/usr/local/lib/php:/usr/local/php/') in /home/me/public_html/hosting/includes/hooks/my_hook.php on line 55

Any assistance would be great :). Thank you.


From the includes/hooks folder, couldn't you just do:

require_once dirname( dirname( __DIR__ ) ) . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'addons' . DIRECTORY_SEPARATOR . 'module_name' . DIRECTORY_SEPARATOR . 'modulefunction.php';

I believe the double dirname on the DIR will get you into the root regardless of your installation.

Need Your Help

Rails 3 RESTful web services with json

ruby-on-rails-3 json web-services rest ruby-on-rails-3.1

I am looking for any basic Ruby on rails tutorial that uses RESTful web services with json, If somebody can throw a very basic app that implement those technologies i would appreciate, I have trie...