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!!!