本文整理匯總了PHP中Doctrine\Common\ClassLoader::loadClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP ClassLoader::loadClass方法的具體用法?PHP ClassLoader::loadClass怎麽用?PHP ClassLoader::loadClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine\Common\ClassLoader
的用法示例。
在下文中一共展示了ClassLoader::loadClass方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testClassLoader
public function testClassLoader()
{
$classLoader = new ClassLoader('ClassLoaderTest');
$classLoader->setIncludePath(__DIR__);
$classLoader->setFileExtension('.class.php');
$classLoader->setNamespaceSeparator('_');
$this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassA'), true);
$this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassB'), true);
$this->assertEquals($classLoader->loadClass('ClassLoaderTest_ClassC'), true);
}
示例2: testClassLoaderCheckFileExists
public function testClassLoaderCheckFileExists()
{
$classLoader = new \Doctrine\Common\ClassLoader();
$classLoader->setBasePath('ClassLoaderTest', __DIR__);
$classLoader->setCheckFileExists(true);
// This would return a fatal error without check file exists true
$this->assertEquals($classLoader->loadClass('SomeInvalidClass'), false);
}
示例3: testMultipleAutoloadRequestsWillProduceSameResult
public function testMultipleAutoloadRequestsWillProduceSameResult()
{
$classLoader = new ClassLoader();
$classLoader->setIncludePath(__DIR__);
$classLoader->setFileExtension('.class.php');
$classLoader->setNamespaceSeparator('_');
$this->assertTrue($classLoader->loadClass('ClassLoaderTest_ClassA'));
$this->assertTrue($classLoader->loadClass('ClassLoaderTest_ClassA'));
}
示例4: ClassLoader
<?php
require_once __DIR__ . '/../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';
require_once __DIR__ . '/../lib/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php';
use Doctrine\Common\ClassLoader;
use Doctrine\Common\Annotations\AnnotationRegistry;
$classLoader = new ClassLoader('Doctrine\\Tests', __DIR__ . '/../tests');
$classLoader->register();
$classLoader = new ClassLoader('Doctrine\\ODM', __DIR__ . '/../lib');
$classLoader->register();
$classLoader = new ClassLoader('Doctrine', __DIR__ . '/../lib/vendor/doctrine-common/lib');
$classLoader->register();
$classLoader = new ClassLoader('Documents', __DIR__);
$classLoader->register();
$classLoader = new ClassLoader('PHPCR\\Util', __DIR__ . '/../lib/vendor/phpcr-utils/src');
$classLoader->register();
$classLoader = new ClassLoader('PHPCR', __DIR__ . '/../lib/vendor/phpcr/src');
$classLoader->register();
$classLoader = new ClassLoader('Symfony\\Component\\Console', __DIR__ . '/../lib/vendor/jackalope/lib/phpcr-utils/lib/vendor');
$classLoader->register();
$classLoader = new ClassLoader('Symfony', __DIR__ . '/../lib/vendor');
$classLoader->register();
AnnotationRegistry::registerLoader(function ($class) use($classLoader) {
$classLoader->loadClass($class);
return class_exists($class, false);
});
AnnotationRegistry::registerFile(__DIR__ . '/../lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');