I am trying to include a file for the ExactTarget api inside a controller. Basically, an ajax request submits a form to a route /send. In the controller for that route I have a class, but it fails when it makes a call to the ExactTarget library.
class sendexacttarget{
public function send($f3)
{
$client = new ExactTargetSoapClient($wsdl, array('trace'=>1));
}
}
I don't want to load the ExactTarget file in the index.php, because then it will load on every request. Ideally, I'd like to just load it here, in the send function. I've tried require() and include() but neither work.
I'm trying to include one file exacttarget.php and that file has a require statement calling soap-wsse.php which has another require statement calling xmlseclibs.php.
So first question: Is it possible to load these files from the controller and if so how?
The second part of the question is this. I am able to combine all of the PHP from those three files into one file and include from the index.php, but I have not been successful calling them as separate files. I have tried this:
$f3->set('AUTOLOAD','App/Controllers/;vendor/exacttarget/xmlseclibs.php;vendor/exacttarget/soap-wsse.php;vendor/exacttarget/exacttarget.php');
But it doesn't work.
I also tried this from another SO thread:
$f3->set('AUTOLOAD','App/Controllers/;vendor/exacttarget/');
$params = require 'vendor/exacttarget/exacttarget.php';
Doesn't work. This last bit of code I thought worked for a bit, but then it stopped working. I'm wondering if there is some caching going on?
In any case, if anyone can please help me include this library, even if on all pages I'd be very grateful. Also, this library I'm using is not available via composer so I don't think using composers autoload is an option.
Thanks.