1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP 5.4 bug. Fatal Error: Class not found

Discussion in 'General PHP and MySQL Discussions' started by Chris D, Aug 20, 2012.

  1. Chris D

    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:

    include_once 'library/AddOn/facebook/src/facebook.php';
    Then other relevant code (beginning on the aforementioned line 508):

    $facebook = new Facebook(array(
    'appId'=> $fbapp_id,
    'secret'=> $fbapp_secret,
    facebook.php (this is the Facebook SDK, not my code) contains:

    class Facebook extends BaseFacebook
    Any ideas on a solution? Again, it works perfectly on 5.3... just a 5.4 specific bug (again).
  2. Arty

    Arty Well-Known Member

    Try adding that path via set_include_path() instead of including php file and let XenForo_Autoloader take care of including classes.
  3. Adam Howard

    Adam Howard Well-Known Member

    Facebook.com's own code is not yet compatible with php 5.4 .... In fact they're using a modified copy of php 5.3.x

    ( It's why someone was able to take them down last month :whistle: )

    With this said... Looking at your array the extra ( ) caught my attention

  4. Chris D

    Chris D XenForo Developer Staff Member

    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
  5. Adam Howard

    Adam Howard Well-Known Member

    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

    = array(
    "foo" => "bar",
    "bar" => "foo",

    // as of PHP 5.4
    $array = [
    "foo" => "bar",
    "bar" => "foo",
    Chris D likes this.
  6. Chris D

    Chris D XenForo Developer Staff Member

    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

    Thank you, by the way Arty (y)

Share This Page