saxulum/saxulum-annotation-manager

This package is abandoned and no longer maintained. No replacement package was suggested.

Saxulum Annotation Manager

1.2.0 2015-12-13 12:18 UTC

This package is auto-updated.

Last update: 2020-09-22 19:08:15 UTC


README

works with plain silex-php

Build Status Total Downloads Latest Stable Version Scrutinizer Code Quality

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'
    )
);