PHP 5.4 bug. Fatal Error: Class not found

Chris D

XenForo developer
Staff member
Ok, so I'm currently testing an add-on I've written (which works perfectly in PHP 5.3) in PHP 5.4 and I am getting a Fatal error. Specifically:

Fatal error: Class 'Facebook' not found in C:\xampp\htdocs\library\AddOn\ControllerPublic\AddOn.php on line 508.

The add-on uses a Facebook API. Here's some relevant code:

PHP:
include_once 'library/AddOn/facebook/src/facebook.php';

Then other relevant code (beginning on the aforementioned line 508):

PHP:
$facebook = new Facebook(array(
          'appId'=> $fbapp_id,
          'secret'=> $fbapp_secret,
));
return $facebook;

facebook.php (this is the Facebook SDK, not my code) contains:

PHP:
class Facebook extends BaseFacebook

Any ideas on a solution? Again, it works perfectly on 5.3... just a 5.4 specific bug (again).
 
Try adding that path via set_include_path() instead of including php file and let XenForo_Autoloader take care of including classes.
 
A bit embarrassing, but do you know what it was?

This was my new install of Windows and I'd installed xampp whereas I normally use WAMP. So, without thinking, I expected everything to work.

I tried Arty's suggestion and using XenForo_Autoloader was the same result, but I started commenting out a few lines to debug the code when I eventually got a different error.

Facebook API then threw a different error. ****ing cURL wasn't installed. It is by default in WAMP but not in xampp :mad:

I thought I'd still have problems but after I enabled cURL and undid all my changes it all started working.

\\ TODO: Add check for cURL on Index page :p
 
A bit embarrassing, but do you know what it was?

This was my new install of Windows and I'd installed xampp whereas I normally use WAMP. So, without thinking, I expected everything to work.

I tried Arty's suggestion and using XenForo_Autoloader was the same result, but I started commenting out a few lines to debug the code when I eventually got a different error.

Facebook API then threw a different error. ****ing cURL wasn't installed. It is by default in WAMP but not in xampp :mad:

I thought I'd still have problems but after I enabled cURL and undid all my changes it all started working.

\\ TODO: Add check for cURL on Index page :p
I'm still so very surprised that you code all that you do in Windows. Seriously still leaves me in awe.

I would still suggest you look over that code example though

PHP:
<?php
$array = array(
    "foo" => "bar",
    "bar" => "foo",
);

// as of PHP 5.4
$array = [
    "foo" => "bar",
    "bar" => "foo",
];
?>

http://php.net/manual/en/language.types.array.php
 
Hmm, how well does [ ] work in older versions of PHP, though?

I'm a Windows man, for my sins. I work in IT and I'm currently responsible for all of the IT at a college, mostly network and servers. I'm a Cisco CCNA and my day job mostly consists of managing around 60 Windows servers and 1 Ubuntu server :LOL:

So I am generally more comfortable in Windows. If I ever have enough money I'll buy a Mac... And then install Windows on it :D


Try adding that path via set_include_path() instead of including php file and let XenForo_Autoloader take care of including classes.
Thank you, by the way Arty (y)
 
Top Bottom