Loading external vendor's in CakePHP 3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Loading external vendor's in CakePHP 3

HVan
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');
$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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Loading external vendor's in CakePHP 3

HVan
Nevermind - I forgot to add use Services_Twilio; at top of the controller.

Duh!

On Wednesday, February 11, 2015 at 2:51:03 PM UTC-8, HVan wrote:
Maybe it's just me but I just can't figure this out. I'm trying to use Twilio (<a href="https://github.com/twilio/twilio-php" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftwilio%2Ftwilio-php\46sa\75D\46sntz\0751\46usg\75AFQjCNEaMhD3220J4-E9yaIXfm3RikQssQ';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftwilio%2Ftwilio-php\46sa\75D\46sntz\0751\46usg\75AFQjCNEaMhD3220J4-E9yaIXfm3RikQssQ';return true;">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');
$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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Loading external vendor's in CakePHP 3

Mani
In reply to this post by HVan
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 (<a href="https://github.com/twilio/twilio-php" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftwilio%2Ftwilio-php\46sa\75D\46sntz\0751\46usg\75AFQjCNEaMhD3220J4-E9yaIXfm3RikQssQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Ftwilio%2Ftwilio-php\46sa\75D\46sntz\0751\46usg\75AFQjCNEaMhD3220J4-E9yaIXfm3RikQssQ&#39;;return true;">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 [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.