cakephpcakephp-2.0cakephp-2.1

Cakephp : Fatal error: Cannot redeclare services_twilio_autoload()


i am working on a Cakephp 2.x.. i am using twilio for sending sms but i am getting this error

Fatal error: Cannot redeclare Services_Twilio_autoload() (previously declared in C:\xampp\htdocs\cakephp\app\Lib\twilio\Twilio.php:3)

how can i sort this issue.. here someone asked the same question and he even tell the solution that how he sort the problem but i didnt get it

https://github.com/twilio/twilio-php/issues/97


Solution

  • The problem is redeclaring the autoload handler in Twilio file. Just update the file twilio/Services/Twilio.php and when it says:

    spl_autoload_register('Services_Twilio_autoload');
    

    change it by

    spl_autoload_register('Services_Twilio_autoload', false);
    

    This way the function will omit messsages when the handler is recalled. You can also check if the handler was created prior to redeclare it. I hope it works!

    Check documentation online at: http://php.net/manual/en/function.spl-autoload-register.php