예제 #1
0
    public function getRegisteredAutoloaders()
    {
        return spl_autoload_functions();
    }
    /**
     * Dynamic new, a simple factory.
     * It loads and constructs a class, with provided arguments.
     *
     * @param   bool     $classname    Classname.
     * @param   array    $arguments    Arguments for the constructor.
     * @return  object
     */
    public static function dnew($classname, array $arguments = [])
    {
        $classname = ltrim($classname, '\\');
        if (false === Consistency::entityExists($classname, false)) {
            spl_autoload_call($classname);
        }
        $class = new \ReflectionClass($classname);
        if (empty($arguments) || false === $class->hasMethod('__construct')) {
            return $class->newInstance();
        }
        return $class->newInstanceArgs($arguments);
    }
}
/**
 * Autoloader.
 */
$autoloader = new Autoloader();
$autoloader->addNamespace('Hoa', dirname(__DIR__));
$autoloader->register();
 /**
  * Add a new namespace together with an array of its corresponding base directories.
  *
  * @param string $namespace_name
  * @param string $corresponding_base_directory
  * @param boolean|null $prepend
  * @see Autoloader::addNamespace(string, string, boolean)
  * @return void
  */
 public function addNamespace(string $namespace_name, string $corresponding_base_directory, $prepend = false)
 {
     $this->autoloader->addNamespace($namespace_name, $corresponding_base_directory, $prepend);
 }
<?php

/**
 * Team Management Tool
 * 
 * This file is the initializer for all requests made to the TMT
 * 
 * @package team-management-tool
 * @license proprietary
 */
namespace TMT;

// Composer Autoloader
require dirname(__FILE__) . "/../vendor/autoload.php";
// Initialize TMT Autoloader
require 'autoload.php';
$al = new Autoloader();
$al->addNamespace("TMT\\app\\", "applications");
$al->addNamespace("TMT\\api\\", "apis");
$al->addNamespace("TMT\\model\\", "models");
$al->addNamespace("TMT\\accessor\\", "accessors");
$al->addNamespace("TMT\\controller\\", "controllers");
$al->addNamespace("TMT\\exception\\", "exceptions");
$al->addNamespace("TMT\\", "libs");
$al->register();
$app = new \TMT\TMT();
$app->handle();
예제 #4
0
파일: bootstrap.php 프로젝트: qimus/graph
<?php

require "app/autoloader.php";
$loader = new Autoloader();
$loader->addNamespace('app', __DIR__ . '/app');
$loader->register();
예제 #5
0
    natsort($classes);
    foreach ($classes as $class) {
        if (stristr($class, 'ComposerAutoloaderInit')) {
            $result = true;
            break;
        }
    }
    return $result;
}
// The base path to /src/ if we don't have Composer we need to know root path
define('CLICKALICIOUS_RNG_BASE_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
// Root node
$root = realpath(CLICKALICIOUS_RNG_BASE_PATH . '../');
// Check for composer existence
if (true === ($composerExist = $composerRunning = file_exists($root . '/vendor/autoload.php'))) {
    include_once $root . '/vendor/autoload.php';
} else {
    $composerExist = $composerRunning = composerRunning();
}
// No need to double detect and so on ...
define('CLICKALICIOUS_RNG_COMPOSER_EXISTS', $composerExist);
define('CLICKALICIOUS_RNG_COMPOSER_RUNNING', $composerRunning);
// Force reporting of all errors ...
error_reporting(-1);
// Init autoloading
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('Clickalicious\\Rng', CLICKALICIOUS_RNG_BASE_PATH . 'Clickalicious\\Rng');
예제 #6
0
        if (stristr($class, 'ComposerAutoloaderInit')) {
            $result = true;
            break;
        }
    }
    return $result;
}
// The base path to /lib/ if we don't have Composer we need to know root path
define('CLICKALICIOUS_MEMCACHED_BASE_PATH', realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
// Root node
$root = realpath(CLICKALICIOUS_MEMCACHED_BASE_PATH . '../');
// Check for composer existence
if (true === ($composerExist = $composerRunning = file_exists($root . '/vendor/autoload.php'))) {
    include_once $root . '/vendor/autoload.php';
} else {
    $composerExist = $composerRunning = composer_running();
}
// No need to double detect and so on ...
define('CLICKALICIOUS_MEMCACHED_COMPOSER_EXISTS', $composerExist);
define('CLICKALICIOUS_MEMCACHED_COMPOSER_RUNNING', $composerRunning);
// Force reporting of all errors ...
error_reporting(-1);
// Retrieve SAPI PHP is running
$sapi = strtolower(php_sapi_name());
// Init autoloading
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('Clickalicious\\Memcached', CLICKALICIOUS_MEMCACHED_BASE_PATH . 'Clickalicious\\Memcached');
예제 #7
0
파일: Init.php 프로젝트: snscripts/docmark
// -------------------------------------------------------------------
// load composer
// -------------------------------------------------------------------
if (file_exists('vendor' . DS . 'autoload.php')) {
    require_once 'vendor' . DS . 'autoload.php';
} else {
    die("Fatal Error: Composer autoload file not found!");
}
// -------------------------------------------------------------------
// Set the root directory and add trailing slash
// -------------------------------------------------------------------
define('ROOT', \Stringy\Stringy::create(dirname(__DIR__), 'UTF-8')->ensureRight(DS));
// -------------------------------------------------------------------
// Set the storage directory (used for auto-updating docs)
// -------------------------------------------------------------------
define('STORAGE_ROOT', ROOT . 'Storage' . DS);
// -------------------------------------------------------------------
// Set the system autoloader
// -------------------------------------------------------------------
if (file_exists(ROOT . 'System' . DS . 'Autoloader.php')) {
    require_once ROOT . 'System' . DS . 'Autoloader.php';
} else {
    die("Fatal Error: System autoload file not found!");
}
$loader = new Autoloader();
$loader->register();
$loader->addNamespace('DocMark', dirname(__DIR__));
// -------------------------------------------------------------------
// Start DocMark
// -------------------------------------------------------------------
$docmark = new \DocMark\System\Docmark();
            if ($this->requireFile($file)) {
                // yes, we're done
                return $file;
            }
        }
        // never found it
        return false;
    }
    /**
     * If a file exists, require it from the file system.
     *
     * @param string $file The file to require.
     *
     * @return bool True if the file exists, false if not.
     */
    protected function requireFile($file)
    {
        if (file_exists($file)) {
            require $file;
            return true;
        }
        return false;
    }
}
// instantiate the loader
$loader = new Autoloader();
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('TokenToMe\\TwitterCards', JM_TC_DIR . 'classes');
예제 #9
0
            // in the relative class name, append with .php
            $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
            // if the mapped file exists, require it
            if ($this->requireFile($file)) {
                // yes, we're done
                return $file;
            }
        }
        // never found it
        return false;
    }
    /**
     * If a file exists, require it from the file system.
     *
     * @param string $file The file to require.
     * @return bool True if the file exists, false if not.
     */
    protected function requireFile($file)
    {
        if (file_exists($file)) {
            require $file;
            return true;
        }
        return false;
    }
}
$loader = new Autoloader();
$loader->register();
$loader->addNamespace('Libs', $GLOBALS['directories']['libs']);
$loader->addNamespace('Services', $GLOBALS['directories']['services']);
$loader->addNamespace('Controllers', $GLOBALS['directories']['controllers']);