works with plain silex-php
- An annotation manager
- php >=5.3
- Doctrine Annotations >=1.1
- Saxulum ClassFinder >=1.0
- Symfony Finder Component >=2.3
Through Composer as saxulum/saxulum-annotation-manager.
Add this line after you added the autoload.php
from composer
\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);
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'
));
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'
);
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())
));
This will return an instance of Saxulum\AnnotationManager\Helper\ClassInfo
based on the given ReflectionClass.
$classInfo = $annotationManager->buildClassInfo(
new \ReflectionClass(new TestClass1())
);
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'
);
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'
)
);