Monday, November 23, 2015

Re: Loading external vendor's in CakePHP 3

Works fine in Cake2 using require_once however falls over in Cake3. How did you get it to work. My code is as follows:

require_once(ROOT.'/vendor/twilio/sdk/Services/Twilio.php'); 
$this->client = new Services_Twilio(Configure::read('Twilio.sid'), Configure::read('Twilio.token'));

I get Class not found error. What do you mean by adding Services_Twilio at the top of the controller?

Any help would be greatly appreciated.


On Wednesday, 11 February 2015 22:51:03 UTC, HVan wrote:
Maybe it's just me but I just can't figure this out. I'm trying to use Twilio (https://github.com/twilio/twilio-php) with Cake 3. I installed via composer. At the top of bootstrap.php it includes vendor/autoload.php, however, no luck; Twilio functions are not called.

So I manually required it inside my controller function and tried calling the class:

require_once(ROOT.'/vendor/twilio/sdk/Services/Twilio.php');Hi
$client = new Services_Twilio(TWILIO_ACCOUNTSID, TWILIO_AUTHTOKEN);

Again, no work and I get this error: Error: Class 'App\Controller\Services_Twilio' not found 

Would appreciate it if someone can point me in the right direction. It really can't be that hard I'm sure. I've used Twilio many times outside of Cake and it was as simple as just requiring it and instantiating the classes.

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: