aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/lib/autoload.php
blob: 8ae094730a63a142d3aceeace90633cdf0eb03ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
function grpcAutoloader($class) {
  $prefix = 'Grpc\\';

  $base_dir = __DIR__ . '/Grpc/';

  $len = strlen($prefix);
  if (strncmp($prefix, $class, $len) !== 0) {
    return;
  }

  $relative_class = substr($class, $len);

  $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';

  if (file_exists($file)) {
    include $file;
  }
}

spl_autoload_register('grpcAutoloader');