31 if (version_compare(PHP_VERSION,
'5.4.0',
'<')) {
32 throw new Exception(
'The Facebook SDK requires PHP version 5.4 or higher.');
35 require_once __DIR__ .
'/polyfills.php';
47 spl_autoload_register(
function ($class) {
49 $prefix =
'Facebook\\';
54 if (defined(
'FACEBOOK_SDK_V4_SRC_DIR')) {
55 $customBaseDir = FACEBOOK_SDK_V4_SRC_DIR;
56 } elseif (defined(
'FACEBOOK_SDK_SRC_DIR')) {
57 $customBaseDir = FACEBOOK_SDK_SRC_DIR;
60 $baseDir = $customBaseDir ?: __DIR__ .
'/';
63 $len = strlen($prefix);
64 if (strncmp($prefix, $class, $len) !== 0) {
70 $relativeClass = substr($class, $len);
75 $file = rtrim($baseDir,
'/') .
'/' . str_replace(
'\\',
'/', $relativeClass) .
'.php';
78 if (file_exists($file)) {