saxulum / saxulum-annotation-manager
Saxulum Annotation Manager
Installs: 2 722
Dependents: 3
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
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
works with plain silex-php
Features
- An annotation manager
Requirements
- php >=5.3
- Doctrine Annotations >=1.1
- Saxulum ClassFinder >=1.0
- Symfony Finder Component >=2.3
Installation
Through Composer as saxulum/saxulum-annotation-manager.
AnnotationRegistry
Add this line after you added the autoload.php
from composer
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(
array($loader, 'loadClass')
);
Usage
Prepare the annotation Manager
use Doctrine\Common\Annotations\AnnotationReader;
use Saxulum\AnnotationManager\Manager\AnnotationManager;
$annotationReader = new AnnotationReader();
$annotationManager = new AnnotationManager($annotationReader);
ClassInfo based on paths
This will search each instantiable class within the given paths
and return em as an array of Saxulum\AnnotationManager\Helper\ClassInfo
instances.
$classInfos = $annotationManager->buildClassInfosBasedOnPaths(array(
dirname(__DIR__) . '/Classes1',
dirname(__DIR__) . '/Classes2'
));
ClassInfo based on path
This will search each instantiable class within the given path
and return em as an array of Saxulum\AnnotationManager\Helper\ClassInfo
instances.
$classInfos = $annotationManager->buildClassInfosBasedOnPath(
dirname(__DIR__) . '/Classes1'
);
ClassInfo based on reflection classes
This will return an array of Saxulum\AnnotationManager\Helper\ClassInfo
instances based on the given ReflectionClasses.
$classInfos = $annotationManager->buildClassInfos(array(
new \ReflectionClass(new TestClass1()),
new \ReflectionClass(new TestClass2())
));
ClassInfo based on reflection class
This will return an instance of Saxulum\AnnotationManager\Helper\ClassInfo
based on the given ReflectionClass.
$classInfo = $annotationManager->buildClassInfo(
new \ReflectionClass(new TestClass1())
);
ReflectionClasses based on path
This will search each instantiable class within the given path
and return em as an array of \ReflectionClass
instances.
$reflectionClasses = AnnotationManager::getReflectionClasses(
dirname(__DIR__) . '/Classes1'
);
Classes based on SplFileInfo
This will search each class within the given file and return em as an array of class names.
$classes = AnnotationManager::findClassesWithinAFile(
new SplFileInfo(
dirname(__DIR__) . '/Classes1/TestClass1.php',
'',
'TestClass1.php'
)
);