r1317@opsdev009 (orig r70384): mcslee | 2007-11-16 16:32:36 -0800
[amiethrift.git] / lib / php / src / autoload.php
blobb5886c5e581ddf85e421163a25dc49654554abb1
1 <?php
3 /**
4 * Copyright (c) 2006- Facebook
5 * Distributed under the Thrift Software License
7 * See accompanying file LICENSE or visit the Thrift site at:
8 * http://developers.facebook.com/thrift/
10 * @package thrift
11 * @author Mark Slee <mcslee@facebook.com>
14 /**
15 * Include this file if you wish to use autoload with your PHP generated Thrift
16 * code. The generated code will *not* include any defined Thrift classes by
17 * default, except for the service interfaces. The generated code will populate
18 * values into $GLOBALS['THRIFT_AUTOLOAD'] which can be used by the autoload
19 * method below. If you have your own autoload system already in place, you
20 * should merge the following functionality into your autoload system.
22 * Generate this code using the -phpa Thrift generator flag.
25 $GLOBALS['THRIFT_AUTOLOAD'] = array();
27 if (!function_exists('__autoload')) {
28 function __autoload($class) {
29 global $THRIFT_AUTOLOAD;
30 if (isset($THRIFT_AUTOLOAD[$class])) {
31 include_once $GLOBALS['THRIFT_ROOT'].'/lib/packages/'.$THRIFT_AUTOLOAD[$class];