Ejemplo n.º 1
0
 private function initAutoloader($rootPath)
 {
     // It is ugly to include the classes here inside the function, but
     // otherwise we would have to use another hardcoded path.
     require_once $rootPath . DIRECTORY_SEPARATOR . Constants::CLASSES_DIR . DIRECTORY_SEPARATOR . 'PathBuilder.php';
     $pathBuilder = PathBuilder::getInstance();
     $pathBuilder->setRootPath($rootPath);
     require_once $pathBuilder->buildAbsolutePath(Constants::CLASSES_DIR, 'Autoloader.php');
     Autoloader::init();
 }
 public static function run()
 {
     Autoloader::init();
     $session = SessionFactory::create();
     $session->setTime('864000');
     //24 hs
     $session->start();
     $requestHandler = RequestHandlerFactory::create();
     $requestHandler->handle($_REQUEST);
 }
Ejemplo n.º 3
0
 /**
  * 运行一个请求生命周期
  * @access public
  * @author songdengtao <http://www.songdengtao.cn>
  * @return void
  */
 public static function run()
 {
     // 系统注册表
     Registry::init(static::get('registryPath'));
     // 运行环境检查
     static::checkEnv();
     // 类文件自动加载
     Autoloader::init(static::getInstance());
     Autoloader::autoload();
     // 设置系统时区
     static::shell('Dtime::setDateDefaultTimeZone');
     // 设置错误处理方法
     static::shell('Error::registerShutdownFunction');
     static::shell('Error::setErrorHandler');
     // 设置异常处理方法
     static::shell('Exception::setExceptionHandler');
     if (false === static::get('isCli')) {
         static::shell('Filter::globalFilter');
         static::shell('Session::start');
     }
     // 路由
     static::shell('Router::dispatch');
     $controller = CONTROLLER_NAME . 'Controller';
     $action = ACTION_NAME . 'Action';
     $class = CONTROLLER_NAMESPACE . '\\' . $controller;
     if (!class_exists($class)) {
         $class = CONTROLLER_NAMESPACE . '\\EmptyController';
         if (!class_exists($class)) {
             $module = strstr(CONTROLLER_NAMESPACE, '\\', true);
             if (static::get('debug')) {
                 if (!is_dir(static::get('appPath') . $module)) {
                     static::shell('Error::halt', 'Call to undefined module ' . $module);
                 } else {
                     static::shell('Error::halt', 'Call to undefined controller ' . $class);
                 }
             } else {
                 static::shell('Error::halt', '404 Not found');
             }
         }
     }
     (new $class())->{$action}();
     return;
 }
Ejemplo n.º 4
0
function includeFunctions($dirname)
{
    $dirhandle = opendir($dirname);
    while (false !== ($filename = readdir($dirhandle))) {
        if ($filename != '.' && $filename != '..' && $filename != '') {
            if ((substr($filename, 0, 9) == 'function.' || substr($filename, 0, 9) == 'constant.') && substr($filename, -4) == '.php') {
                include $dirname . $filename;
            }
            if (is_dir($dirname . $filename)) {
                includeFunctions($dirname . $filename . '/');
            }
        }
    }
    closedir($dirhandle);
}
Autoloader::init();
/**
 * Class Autoloader
 *
 * iterates through given directory and includes
 * the file which matches $classname
 *
 * @copyright  (c) the authors
 * @author     Froxlor team <*****@*****.**> (2013-)
 * @license    GPLv2 http://files.froxlor.org/misc/COPYING.txt
 * @package    Autoloader
 * @since      0.9.29.1
 */
class Autoloader
{
    /**
Ejemplo n.º 5
0
<?php

class Autoloader
{
    private static $basepath;
    public static function init($basepath)
    {
        self::$basepath = $basepath;
        spl_autoload_register('Autoloader::loader');
    }
    public static function loader($className)
    {
        if (strpos($className, 'connected') !== false) {
            $fileName = self::$basepath . '/' . str_replace("\\", "/", str_replace("connected\\", "", $className)) . ".php";
            if (file_exists($fileName)) {
                require_once $fileName;
                if (class_exists($className)) {
                    return true;
                }
            }
        }
        return false;
    }
}
Autoloader::init(dirname(__FILE__));
Ejemplo n.º 6
0
<?php

namespace Redaxscript;

/* autoload */
include_once 'includes/Autoloader.php';
include_once 'TestCaseAbstract.php';
/* deprecated */
include_once 'includes/query.php';
/* init */
$autoloader = new Autoloader();
$autoloader->init();
/* get instance */
$registry = Registry::getInstance();
$config = Config::getInstance();
/* config */
$dbUrl = getenv('DB_URL');
if ($dbUrl) {
    $config->parse($dbUrl);
} else {
    $config->set('dbType', 'sqlite');
    $config->set('dbHost', ':memory:');
}
/* database */
Db::construct($config);
Db::init();
/* installer */
$installer = new Installer($config);
$installer->init();
$installer->rawDrop();
$installer->rawCreate();
Ejemplo n.º 7
0
<?php

/**
 *
 * This file is part of the Apix Project.
 *
 * (c) Franck Cassedanne <franck at ouarz.net>
 *
 * @license     http://opensource.org/licenses/BSD-3-Clause  New BSD License
 *
 */
namespace Apix;

define('UNIT_TEST', true);
define('APP_TOPDIR', realpath(__DIR__ . '/../php'));
define('APP_TESTDIR', realpath(__DIR__));
define('APP_VENDOR', realpath(__DIR__ . '/../../vendor'));
// @TODO: this won't work with PEAR
require APP_VENDOR . '/apix/autoloader/src/php/Apix/Autoloader.php';
Autoloader::init(array(APP_TOPDIR, APP_TESTDIR, APP_VENDOR));
Ejemplo n.º 8
0
<?php

//C:\wamp\bin\php\php5.5.12\php.exe
require 'engine/autoloader.php';
$avtoloader = Autoloader::init();
$paths = array('app/libs', 'app/controllers');
$avtoloader->load($paths);
///
require 'vendor/autoload.php';
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);
$http = new React\Http\Server($socket);
///
$queue = new queueHandler();
///
$http->on('request', function ($request, $response) {
    $answer = 'void';
    $query = $request->getQuery();
    $path = $request->getPath();
    $dispatcher = Dispatcher::getInstance();
    $answer = $dispatcher->run($query, $path);
    if (isset($query['param'])) {
        if ($query['param'] == 'time') {
            $answer = microtime(true);
        }
        if ($query['param'] == 'die') {
            echo 'Die';
            exit;
        }
    }
    $response->writeHead(200, array('Content-Type' => 'text/plain'));
Ejemplo n.º 9
0
 /**
  * @covers Microsite\Autoloader::load
  * @covers Microsite\Autoloader::register
  * @covers Microsite\Autoloader::init
  */
 public function testLoad()
 {
     Autoloader::init();
     Autoloader::register('Testing', BOOTSTRAP_DIR . '/data');
     $this->assertTrue(\Testing\TestClass::get_true());
 }
Ejemplo n.º 10
0
<?php

include_once 'classes/Config.php';
include_once 'classes/Autoloader.php';
error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', 1);
Autoloader::init(Config::get('fulldir'));
setlocale(LC_ALL, "es_ES");
date_default_timezone_set("Europe/Madrid");
session_start();