Sorry to ask a newby question like thisā¦Iām sure this is sillyā¦but:
Having difficulty with a āuseā statement āinsideā a classā¦not sure how to implement.
Iām building a LogicHook to query the Twilio API to āvalidateā that a given phone number is a āMobileā number.
Iām using the Twilio APKā¦with used composer to install, and has an autoload file.
In the sample code provided by Twilio (which DOES work āoutsideā of a Class), it includes some files, and uses a āuseā statement like this.
// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once __DIR__ . '/../../../AMS/vendor/autoload.php';
require_once __DIR__ . '/../../../AMS/config.php';
use Twilio\Rest\Client;
However, obviously (even to me) you canāt access the ārequiredā file, and itās variables etc, āinsideā a class in a class file.
If I include the ārequiresā INSIDE the class definition, all is well, and I have access to all the variables I need from my āconfigā fileā¦but the āUseā statement causes an error if I put āitā inside the class.
This ERRORS:
class accountsMobilePhoneValidation
{
public function validateMobileNumber($bean, $event, $arguments)
{
require_once __DIR__ . '/../../../AMS/vendor/autoload.php';
require_once __DIR__ . '/../../../AMS/config.php';
use Twilio\Rest\Client; // <- this line causes the error......
}
}
Any advice???
Againā¦sorry for the n00b question.
Thanks all!!!