drupal_get_path function for third party PHP includes files

by Adutwum   Last Updated March 14, 2019 20:07 PM

I am trying to add some PHP includes files into Drupal 7 site. The files are on this page - https://developer.salesforce.com/docs/atlas.en-us.noversion.mc-apis.meta/mc-apis/connecting_to_the_api_using_php.htm under the "Required PHP Includes" heading. It looks like I need these files: soap-wsse.php, exacttarget_soap_client.php, xmlseclibs.php in my Drupal install.

I will need to use the require('exacttarget_soap_client.php') function in a Drupal custom module.

My question is where to place these files in the file structure of Drupal and what would be the $type using drupal_get_path() function? Should I be using the Libraries API instead?

Tags : 7

Answers 1

drupal_get_path() returns the path of a module, a theme, a theme engine, or a profile. It's not for loading a generic PHP file, for which you need module_load_include() which (despite the name) can be used for a PHP file that can be loaded with require_once.

Supposing that you add the soap-wsse.php file in the includes directory of the test_module module, you cal load that file using the following code.

module_load_include('php', 'test_module', 'includes/soap-wsse');
March 14, 2019 20:04 PM

Related Questions