1<?php 2 3define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\"); 4define("GOOGLE_NAMESPACE", "Google\\Protobuf\\"); 5define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\"); 6 7function protobuf_autoloader_impl($class, $prefix) { 8 $length = strlen($prefix); 9 if ((substr($class, 0, $length) === $prefix)) { 10 $path = '../php/src/' . implode('/', array_map('ucwords', explode('\\', $class))) . '.php'; 11 include_once $path; 12 } 13} 14 15function protobuf_autoloader($class) { 16 protobuf_autoloader_impl($class, GOOGLE_INTERNAL_NAMESPACE); 17 protobuf_autoloader_impl($class, GOOGLE_NAMESPACE); 18 protobuf_autoloader_impl($class, GOOGLE_GPBMETADATA_NAMESPACE); 19} 20 21spl_autoload_register('protobuf_autoloader'); 22