本文整理汇总了PHP中ClassLoader::addPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassLoader::addPath方法的具体用法?PHP ClassLoader::addPath怎么用?PHP ClassLoader::addPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::addPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readPacket
protected function readPacket()
{
if (strlen($packet = $this->thread->readMainToThreadPacket()) > 0) {
$pid = ord($packet[0]);
$offset = 1;
if ($pid === self::PACKET_REQUEST_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkX = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$chunkZ = Binary::readInt(substr($packet, $offset, 4));
$this->enqueueChunk($levelID, $chunkX, $chunkZ);
} elseif ($pid === self::PACKET_SEND_CHUNK) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$len = ord($packet[$offset++]);
/** @var FullChunk $class */
$class = substr($packet, $offset, $len);
$offset += $len;
$chunk = $class::fromBinary(substr($packet, $offset));
$this->receiveChunk($levelID, $chunk);
} elseif ($pid === self::PACKET_OPEN_LEVEL) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$seed = Binary::readInt(substr($packet, $offset, 4));
$offset += 4;
$len = Binary::readShort(substr($packet, $offset, 2));
$offset += 2;
$class = substr($packet, $offset, $len);
$offset += $len;
$options = unserialize(substr($packet, $offset));
$this->openLevel($levelID, $seed, $class, $options);
} elseif ($pid === self::PACKET_CLOSE_LEVEL) {
$levelID = Binary::readInt(substr($packet, $offset, 4));
$this->closeLevel($levelID);
} elseif ($pid === self::PACKET_ADD_NAMESPACE) {
$len = Binary::readShort(substr($packet, $offset, 2));
$offset += 2;
$namespace = substr($packet, $offset, $len);
$offset += $len;
$path = substr($packet, $offset);
$this->loader->addPath($path);
} elseif ($pid === self::PACKET_SHUTDOWN) {
foreach ($this->levels as $level) {
$level->shutdown();
}
$this->levels = [];
$this->shutdown = true;
}
} elseif (count($this->thread->getInternalQueue()) === 0) {
$this->thread->synchronized(function () {
$this->thread->wait(50000);
});
}
}
示例2: ClassLoader
if ($class) {
$file = str_replace('\\', '/', $class);
$file .= '.php';
if (file_exists($file)) {
include $file;
}
}
});
require_once 'ClassLoader.php';
$blocking = true;
$loader = new ClassLoader(__NAMESPACE__, __DIR__, $blocking);
$loader->register();
// Add a custom user path, relative is ok.
// System paths are included by default, but are searched last after all
// namespace and user provided paths.
$loader->addPath('../cache');
try {
//$consumer = new OAuthConsumer();
// should fail
// $jim = new Jim();
// $jim = new \cache\example();
example2::ttt();
echo PHP_EOL;
example::ttt();
} catch (ClassNotFoundException $ex) {
echo "Unable to load a class: <br />";
echo "Class Name: " . $ex->className() . "<br />";
echo "Attempted Paths: ";
var_dump($ex->attempted());
echo "<br />";
}
示例3: bootstrap
public static function bootstrap(\ClassLoader $loader)
{
$loader->addPath(\dirname("<stdin>") . DIRECTORY_SEPARATOR . "..");
}
示例4: catch
<?php
/**
* Created by IntelliJ IDEA.
* User: tueda
* Date: 15/09/10
* Time: 11:18
*/
include_once __DIR__ . "/env.php";
require_once LIBRARY_PATH . "/etc/ApiConfig.php";
require_once LIBRARY_PATH . "/common/ClassLoader.php";
ClassLoader::addPath(array(LIBRARY_PATH . '/' . ApiConfig::$API_ETC, LIBRARY_PATH . '/' . ApiConfig::$API_COMMON, LIBRARY_PATH . '/' . ApiConfig::$API_ABST, LIBRARY_PATH . '/' . ApiConfig::$API_OBJECTS, LIBRARY_PATH . '/' . ApiConfig::$API_IMPLE, LIBRARY_PATH . '/' . ApiConfig::$LOG4PHP_DIR));
spl_autoload_register(array('ClassLoader', '_autoLoad'));
ApiLogger::__init(array('log4php.properties'));
try {
$strApi = $_GET["api"];
$api = new $strApi();
$api->action();
} catch (Exception $e) {
ApiLogger::fatal($e);
}
示例5: DbConnection
<?php
/**
* Created by IntelliJ IDEA.
* User: tueda
* Date: 15/09/22
* Time: 15:27
*/
include_once __DIR__ . "/env.php";
require_once SRC_PATH . "/etc/DbConfig.php";
require_once SRC_PATH . "/common/ClassLoader.php";
ClassLoader::addPath(array(LIBRARY_PATH . '/' . DbConfig::$DB_ROW, LIBRARY_PATH . '/' . DbConfig::$DB_QUERY, LIBRARY_PATH . '/' . DbConfig::$DB_EXCEPTION, SRC_PATH . '/' . DbConfig::$DB_ETC, SRC_PATH . '/' . DbConfig::$DB_COMMON, SRC_PATH . '/' . DbConfig::$DB_SAMPLE));
spl_autoload_register(array('ClassLoader', '_autoLoad'));
try {
$dbh = new DbConnection();
$mysqlnd = function_exists('mysqli_fetch_all');
if ($mysqlnd) {
print "mysqlnd enabled!" . "\n";
}
$clver = $dbh->getConnection()->getAttribute(PDO::ATTR_CLIENT_VERSION);
if (strpos($clver, 'mysqlnd') !== false) {
print "PDO MySQLnd enabled! : " . $clver . "\n";
}
$ite = new SimpleBlancoSelectAllIterator($dbh->getConnection());
$ite->prepareStatement();
$stmt = $ite->getStatement();
while ($ite->next()) {
$row = $ite->getRow();
print $row . "\n";
}
} catch (Exception $e) {
示例6: bootstrap
public static function bootstrap(\ClassLoader $loader)
{
$loader->addPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . "..");
}