Protocol Buffers - Google's data interchange format (grpc依赖)
https://developers.google.com/protocol-buffers/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
879 B
25 lines
879 B
<?php |
|
|
|
define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\"); |
|
define("GOOGLE_NAMESPACE", "Google\\Protobuf\\"); |
|
define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\"); |
|
|
|
function protobuf_autoloader_impl($class, $prefix) { |
|
$length = strlen($prefix); |
|
if ((substr($class, 0, $length) === $prefix)) { |
|
$path = 'src/' . implode('/', array_map('ucwords', explode('\\', $class))) . '.php'; |
|
if (file_exists('php/' . $path)) { |
|
include_once 'php/' . $path; |
|
} else { |
|
include_once 'php/generated/' . $path; |
|
} |
|
} |
|
} |
|
|
|
function protobuf_autoloader($class) { |
|
protobuf_autoloader_impl($class, GOOGLE_INTERNAL_NAMESPACE); |
|
protobuf_autoloader_impl($class, GOOGLE_NAMESPACE); |
|
protobuf_autoloader_impl($class, GOOGLE_GPBMETADATA_NAMESPACE); |
|
} |
|
|
|
spl_autoload_register('protobuf_autoloader');
|
|
|