當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ClassLoader::loadClass方法代碼示例

本文整理匯總了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);
 }
開發者ID:jacques-sounvi,項目名稱:addressbook,代碼行數:10,代碼來源:ClassLoaderTest.php

示例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);
 }
開發者ID:jackbravo,項目名稱:doctrine,代碼行數:8,代碼來源:ClassLoaderTest.php

示例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'));
 }
開發者ID:Dren-x,項目名稱:mobitnew,代碼行數:9,代碼來源:ClassLoaderTest.php

示例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');
開發者ID:nicam,項目名稱:phpcr-odm,代碼行數:27,代碼來源:bootstrap.php


注:本文中的Doctrine\Common\ClassLoader::loadClass方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。