本文整理汇总了PHP中Autoloader::addPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Autoloader::addPath方法的具体用法?PHP Autoloader::addPath怎么用?PHP Autoloader::addPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Autoloader
的用法示例。
在下文中一共展示了Autoloader::addPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLoad
public function testLoad()
{
$autoloader = new Autoloader();
$autoloader->addPath('Foo', 'src/Cache');
$autoloader->addPath('Foo', 'src/I18n');
// $autoloader->addPath('Foo\Selection', 'src/Models/Selection');
$this->assertFalse($autoloader->load('Bar'));
$this->assertFalse($autoloader->load('Foo\\Bar'));
$this->assertTrue($autoloader->load('Foo\\I18n'));
$this->assertTrue($autoloader->load('Foo\\Cache'));
// $this->assertTrue($autoloader->load('Foo\Selection\SelectionBuilder'));
// TODO: mock loadFrom and test paths etc.
}
示例2: Autoloader
<?php
/**
* Project name: Webist MVC
* @/webist/mvc
* @name index.php
* @author Webist
* Created at : Dec 21, 2014 1:53:05 PM
* UTF-8
*
* test post data
* print "<form method=post><input type=text name=xx value=11><input type=submit></form>";
*/
require_once "../src/Autoloader.php";
$autoloader = new Autoloader();
//we are in public dir. One-up to be able to load (non-public) app files.
$autoloader->addPath(dirname(__DIR__));
//Add document_root for both http and cli environments
$argc = filter_input(INPUT_SERVER, 'argc', FILTER_SANITIZE_STRING);
define("DOCROOT", str_replace("\\", DIRECTORY_SEPARATOR, ((isset($argc) ? $argc : null) >= 1 === true ? PHP_SAPI : "apache") == "cli" ? dirname(__FILE__) : getcwd()));
$autoloader->addPath(DOCROOT);
//Prepare the input reads
$request = new src\vendor\Webist\Request();
//Prepare Handler by letting the Router match the request with a pre-defined route
$router = new src\vendor\Webist\Router();
//
$invoker = new app\base\Dispatcher();
$invoker->dispatch($request, $router);
//test memory usage etc.
//$test = new src\vendor\Webist\Test;
//print $test->results();