public static function createUdpApplication($config) { AutoLoad::addRoot(dirname(dirname($config))); SysLog::init(UserConfig::getConfig('log')); return new YaafUdpServ(); // return $class; //进行路由解析等 }
/** * pase uma pasta onde ele ira procurar seus objetos. * * @param string $path */ public static function setPath($path, $prioridade = 0) { $reordenar = !isset(self::$paths[$prioridade]); if (is_dir($path)) { self::$paths[$prioridade][] = $path; } if ($reordenar) { ksort(self::$paths); self::$paths = array_reverse(self::$paths); } }
/** * 加载 modules 的路径到 path * @return */ public static function modules(array $modules = NULL) { if ($modules != NULL) { self::$_modules = $modules; } $paths = array(); foreach (self::$_modules as $name => $path) { if (is_dir($path)) { $paths[] = realpath($path) . DIRECTORY_SEPARATOR; } else { continue; } } self::$_paths = $paths; }
public static function run($app, $controller = null, $action = null) { self::$app = $app; $autoload = AutoLoad::getInstance(); //加载配置文件 $config = DOCUMENT_ROOT . DS . 'app' . DS . $app . DS . 'config.php'; if (!is_file($config)) { throw new \Exception($app . '应用缺少config文件', 0); } else { require $config; self::$config = new \Config(); self::$config->loader($autoload); } //分发路由 $route = new Route($app); $route->execute($controller, $action); }
<?php require_once __DIR__ . '/lib/AutoLoad.class.php'; AutoLoad::register();
<?php require 'Engine/AutoLoad.php'; AutoLoad::Start(); //Engine\Generic\Server::ShowServerVars(); $app = new Application\Application(); $app->UseSession = false; $app->SessionTimeOut = 3; $app->Start(); //$app->Session->SetLogin(TRUE); //(new Engine\App\Config())->PrintProperties(); //(new Engine\App\Session())->PrintProperties();
/** * [setRoot 设置root根目录,可以同时添加多个] * @param array $root [array] */ public static function setRoot($rootArr = array()) { if (is_array($rootArr)) { self::$root_path = array_merge(self::$root_path, $rootArr); } }
<?php /** Autoload Framework @author rizkyabdilah @date July 7, 2011 */ // ini_set('display_errors', 1); // error_reporting(E_ALL); define('APP_PATH', dirname(__FILE__).'/autoload'); define('CORE_PATH', APP_PATH.'/core'); define('LIBR_PATH', APP_PATH.'/libr'); require_once(APP_PATH.'/config.php'); require_once(CORE_PATH.'/Autoload.php'); $AL = new AutoLoad($config); $AL->run();
$file = array_pop($file); $bptw = substr($_SERVER['PHP_SELF'], 0, -(strlen($file) + 1)); $qyst = (!empty($_SERVER['QUERY_STRING']) ? '?' : '') . $_SERVER['QUERY_STRING']; $rdtu = str_replace($qyst, '', $_SERVER['REQUEST_URI']); $bsgt = trim(str_replace($bptw, '', $rdtu), "/"); $_ll['url']['home'] = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $bptw . '/'; $_ll['url']['path'] = $bsgt; $_ll['url']['base'] = $_ll['url']['home'] . $_ll['url']['path']; $_ll['url']['full'] = $_ll['url']['base'] . $qyst; $_ll['url']['get'] = !empty($bsgt) ? explode('/', $bsgt) : array(); unset($file, $bptw, $qyst, $rdtu, $bsgt); /** Carregando e configunado o Autoload */ require_once BASE_PATH . DS . 'usr' . DS . 'AutoLoad.php'; AutoLoad::setPath(BASE_PATH . DS . 'usr'); AutoLoad::setPath(BASE_PATH . DS . 'api'); AutoLoad::setPath(BASE_PATH . DS . 'app'); /** Verifica a existemcia do inicialozador (confg.php) */ if (!file_exists($f = BASE_PATH . DS . 'etc' . DS . 'confg.ll')) { die('file: ' . $f . '; não existemte.'); } else { $_ll = array_merge($_ll, Confgs::getFile($f)); } /** starta todas os difines configurados */ foreach ($_ll['defines'] as $name => $value) { if (!defined($name)) { define($name, $value); } } /** retorna os dados processados/carregados pelo start */ if (str_replace('/', DS, trim($_SERVER['DOCUMENT_ROOT'], DS) . $_SERVER['SCRIPT_NAME']) !== trim(str_replace('/', DS, __FILE__), DS)) { return $_ll;
function __autoload($classname) { AutoLoad::load($classname); }
public static function register() { if (!is_object(self::$_obj)) { self::$_obj = new AutoLoad(); } }
<?php /** auto load subistituto */ AutoLoad::setPath(BASE_PATH . DS . 'api' . DS . 'phpmailer'); /** * PHPMailer - PHP email creation and transport class. * PHP Version 5 * @package PHPMailer * @link https://github.com/PHPMailer/PHPMailer/ The PHPMailer GitHub project * @author Marcus Bointon (Synchro/coolbru) <*****@*****.**> * @author Jim Jagielski (jimjag) <*****@*****.**> * @author Andy Prevost (codeworxtech) <*****@*****.**> * @author Brent R. Matzelle (original founder) * @copyright 2012 - 2014 Marcus Bointon * @copyright 2010 - 2012 Jim Jagielski * @copyright 2004 - 2009 Andy Prevost * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License * @note This program is distributed in the hope that it will be useful - WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. */ /** * PHPMailer - PHP email creation and transport class. * @package PHPMailer * @author Marcus Bointon (Synchro/coolbru) <*****@*****.**> * @author Jim Jagielski (jimjag) <*****@*****.**> * @author Andy Prevost (codeworxtech) <*****@*****.**> * @author Brent R. Matzelle (original founder) */ class PHPMailer {
/** * 自动载入实例化对象 */ public function loadObject() { require_once dirname(__FILE__) . '/AutoLoad.php'; $autoload = new AutoLoad(); $autoload->register(); }