当前位置: 首页>>代码示例>>PHP>>正文


PHP Autoloader::addNamespace方法代码示例

本文整理汇总了PHP中Autoloader::addNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Autoloader::addNamespace方法的具体用法?PHP Autoloader::addNamespace怎么用?PHP Autoloader::addNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Autoloader的用法示例。


在下文中一共展示了Autoloader::addNamespace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRegisteredAutoloaders

    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();
开发者ID:Metalaka,项目名称:Consistency,代码行数:31,代码来源:Autoloader.php

示例2: addNamespace

 /**
  * 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);
 }
开发者ID:Karabow-Inc,项目名称:Pluginizer-framework,代码行数:13,代码来源:autoloader_register.php

示例3: dirname

<?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();
开发者ID:byu-oit-ssengineering,项目名称:team-managment-tool,代码行数:27,代码来源:init.php

示例4: Autoloader

<?php

require "app/autoloader.php";
$loader = new Autoloader();
$loader->addNamespace('app', __DIR__ . '/app');
$loader->register();
开发者ID:qimus,项目名称:graph,代码行数:6,代码来源:bootstrap.php

示例5: natsort

    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');
开发者ID:clickalicious,项目名称:rng,代码行数:30,代码来源:Bootstrap.php

示例6: realpath

        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');
开发者ID:xiaobailc,项目名称:Memcached.php,代码行数:30,代码来源:Bootstrap.php

示例7: die

// -------------------------------------------------------------------
// 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();
开发者ID:snscripts,项目名称:docmark,代码行数:31,代码来源:Init.php

示例8: requireFile

            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');
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:30,代码来源:autoload.php

示例9: requireFile

            // 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']);
开发者ID:Fedeorlandau,项目名称:ArnoldPHP,代码行数:31,代码来源:autoload.php


注:本文中的Autoloader::addNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。