code-exchange icon indicating copy to clipboard operation
code-exchange copied to clipboard

Uncaught TypeError: Return value of SplClassLoader::register() must be an instance of void, none returned

Open salvarezmx opened this issue 5 years ago • 8 comments

I'm getting this error when running the basic code


Fatal error: Uncaught TypeError: Return value of SplClassLoader::register() must be an instance of void, none returned in /home/membersf/global/php/twilio/twilio-php-master/src/Twilio/autoload.php:115 Stack trace: #0 /home/membersf/global/php/twilio/twilio-php-master/src/Twilio/autoload.php(146): SplClassLoader->register() #1 /home/membersf/global/php/twilio/twilio.php(11): require_once('/home/membersf/...') #2 /home/membersf/public_html/php/membersfai_framework.php(139): require_once('/home/membersf/...') #3 /home/membersf/public_html/php/proceso.php(106): aplicarMembresia('1', '52', '4310', '1', 'MEMBRESIA') #4 {main} thrown in /home/membersf/global/php/twilio/twilio-php-master/src/Twilio/autoload.php on line 115

this is the code I'm running

require_once DIR .'/twilio-php-master/src/Twilio/autoload.php'; //file_put_contents('lll.txt', 'twilio-php-master/src/Twilio/autoload.php'); //use Twilio\Rest\Client; // Your Account SID and Auth Token from twilio.com/console $account_sid = ''; $auth_token = ''; // In production, these should be environment variables. E.g.: // $auth_token = $_ENV["TWILIO_ACCOUNT_SID"] // A Twilio number you own with SMS capabilities $twilio_number = "";

$client = new Twilio\Rest\Client($account_sid, $auth_token);
$client->messages->create(
	$number,
	array(
		'from' => $twilio_number,
		'body' => $text
	)
);

salvarezmx avatar Feb 27 '20 04:02 salvarezmx

Using php 7.2

salvarezmx avatar Feb 27 '20 04:02 salvarezmx

Hi @salvarezmx!

You accidentally posted your credentials as part of your code here. I removed them but could you please go and rotate a new auth token.

I have someone look at your error in the meantime.

dkundel avatar Feb 27 '20 06:02 dkundel

Hi @salvarezmx - could you post a copy of your composer.json file please? I'll try and replicate your problem my end and help you out.

GeeH avatar Feb 27 '20 08:02 GeeH

Hi, I am getting the same error. I have not installed composer. Could I get some help on this?

messages->create( // Where to send a text message (your cell phone?) '+123456789', array( 'from' => $twilio_number, 'body' => 'I sent this message in under 10 minutes!' ) ); Basically running the code from https://www.twilio.com/docs/sms/quickstart/php-manual-install?code-sample=code-reply-to-a-sms-using-php-1&code-language=PHP&code-sdk-version=5.x Am having PHP 7.0.33-0ubuntu0.16.04.15 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.33-0ubuntu0.16.04.15, Copyright (c) 1999-2017, by Zend Technologies

shanthi1130 avatar Sep 03 '20 23:09 shanthi1130

Fatal error: Uncaught TypeError: Return value of SplClassLoader::register() must be an instance of void, none returned in C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php:115 Stack trace: #0 C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php(146): SplClassLoader->register() #1 C:\server 2\www\sms\sms.php(4): require('C:\server 2\www...') #2 {main} thrown in C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php on line 115

I am having the same error running on PHP 7.2

StaticB1 avatar Oct 05 '20 07:10 StaticB1

I am facing same error on my server too but works fine in localhost

divyang19 avatar Oct 23 '20 12:10 divyang19

i upgraded to php 7.2 then download a file called cacert.pem then put its directory path in php.ini file as illustrated below

curl.cainfo = "C:/Server2/cacert.pem"

Fatal error: Uncaught TypeError: Return value of SplClassLoader::register() must be an instance of void, none returned in C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php:115 Stack trace: #0 C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php(146): SplClassLoader->register() #1 C:\server 2\www\sms\sms.php(4): require('C:\server 2\www...') #2 {main} thrown in C:\server 2\www\sms\twilio-php-main\src\Twilio\autoload.php on line 115

I am having the same error running on PHP 7.2

StaticB1 avatar Oct 23 '20 14:10 StaticB1

In case someone passes by: I had the same issue and the problem was an incompatible version of PHP (7.0), and after upgrading to PHP 7.4 the error disappeared. After checking, as of today the Twilio SDK requires PHP 7.2 and above.

julienpa avatar Dec 04 '20 14:12 julienpa