本文整理汇总了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');