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

有帮助吗?

解决方案

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

其他提示

This error will occur when you include Twilio.php more than one. The solution in selected right answer will skip throwing error messages only. That will also stop throwing other errors. Right solution- Call the twilio.php with require_once function not with require everywhere. This will not include file again if already loaded.

require_once('twilio.php');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top