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); }); } }
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 />"; }
public static function bootstrap(\ClassLoader $loader) { $loader->addPath(\dirname("<stdin>") . DIRECTORY_SEPARATOR . ".."); }
<?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); }
<?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) {
public static function bootstrap(\ClassLoader $loader) { $loader->addPath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".."); }