saxulum / saxulum-annotation-manager
此软件包已被废弃,不再维护。未建议替代包。
Saxulum 注释管理器
1.2.0
2015-12-13 12:18 UTC
Requires
- php: >=5.3.9,<8.0
- doctrine/annotations: ~1.1
- saxulum/saxulum-classfinder: ~1.1,>=1.1.2
- symfony/finder: ~2.3|~3.0
Requires (Dev)
- phpunit/phpunit: ~4.0
README
与 plain silex-php 兼容
功能
- 注释管理器
要求
- php >=5.3
- Doctrine Annotations >=1.1
- Saxulum ClassFinder >=1.0
- Symfony Finder Component >=2.3
安装
通过 Composer 以 saxulum/saxulum-annotation-manager 的形式。
AnnotationRegistry
在您添加了 composer 的 autoload.php
之后添加此行
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(
array($loader, 'loadClass')
);
使用
准备注释管理器
use Doctrine\Common\Annotations\AnnotationReader;
use Saxulum\AnnotationManager\Manager\AnnotationManager;
$annotationReader = new AnnotationReader();
$annotationManager = new AnnotationManager($annotationReader);
基于路径的 ClassInfo
这将在给定路径中的每个可实例化类中进行搜索,并将它们作为 Saxulum\AnnotationManager\Helper\ClassInfo
实例的数组返回。
$classInfos = $annotationManager->buildClassInfosBasedOnPaths(array(
dirname(__DIR__) . '/Classes1',
dirname(__DIR__) . '/Classes2'
));
基于路径的 ClassInfo
这将在给定路径中的每个可实例化类中进行搜索,并将它们作为 Saxulum\AnnotationManager\Helper\ClassInfo
实例的数组返回。
$classInfos = $annotationManager->buildClassInfosBasedOnPath(
dirname(__DIR__) . '/Classes1'
);
基于反射类的 ClassInfo
这将基于给定的 ReflectionClasses 返回一个包含 Saxulum\AnnotationManager\Helper\ClassInfo
实例的数组。
$classInfos = $annotationManager->buildClassInfos(array(
new \ReflectionClass(new TestClass1()),
new \ReflectionClass(new TestClass2())
));
基于反射类的 ClassInfo
这将基于给定的 ReflectionClass 返回一个 Saxulum\AnnotationManager\Helper\ClassInfo
实例。
$classInfo = $annotationManager->buildClassInfo(
new \ReflectionClass(new TestClass1())
);
基于路径的 ReflectionClasses
这将在给定路径中的每个可实例化类中进行搜索,并将它们作为 \ReflectionClass
实例的数组返回。
$reflectionClasses = AnnotationManager::getReflectionClasses(
dirname(__DIR__) . '/Classes1'
);
基于 SplFileInfo 的类
这将在给定文件中的每个类中进行搜索,并将它们作为类名的数组返回。
$classes = AnnotationManager::findClassesWithinAFile(
new SplFileInfo(
dirname(__DIR__) . '/Classes1/TestClass1.php',
'',
'TestClass1.php'
)
);