Download the PHP package phramz/doctrine-annotation-scanner without Composer
On this page you can find all versions of the php package phramz/doctrine-annotation-scanner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phramz/doctrine-annotation-scanner
More information about phramz/doctrine-annotation-scanner
Files in phramz/doctrine-annotation-scanner
Package doctrine-annotation-scanner
Short Description library to scan files and folders for annotated classes using doctrine annotations
License MIT
Homepage https://github.com/phramz/doctrine-annotation-scanner
Informations about the package doctrine-annotation-scanner
Annotation Scanner
Annotation Scanner is a library to scan files and folders for annotated classes using doctrine annotations.
Install
It's easy if you use composer!
edit your composer.json
or via command line
License
This library is licensed under the MIT license. For further information see LICENSE file.
Known limitations
Your code has to meet the following conditions to make this library work properly:
- Follow the PSR-0 conventions.
- One classfile contains exactly one class.
- The classfile is named after the class it contains plus
.php
suffix.
- Since this library won't do any autoloading stuff its up to you to ensure that all
classes are autoloaded or manually loaded (e.g. by using
require_once
). - Make sure that you registered your custom annotations via the
AnnotationRegistry
. See Doctrine Common documentation for details.
Examples
The library offers two different ways to find annotated classfiles:
- If your just interested to find out which files contain annotated classes
you can take advantage of the
Finder
- If you need to find the classfiles but want to access the concrete annotations as well
the
Scanner
is your friend.
Now, have a look at the following examples ...
Finder
The following example will find any classfile under /tests
that contains either @Foo
or @Bar
annotations in
property, method or class-docblocks.
You can access the search result by iterating over the Finder
instance. For each classfile you'll get an instance of
Symfony\Component\Finder\SplFileInfo
.
For more information about the Finder
have a look at the Symfony2 Finder documentation.
Scanner
The following example will find any classfile under /tests
that contains either @Foo
or @Bar
annotations in
property, method or class-docblocks.
You can access the search result by iterating over the Scanner
instance. For each classfile you'll get an instance of
Phramz\Doctrine\Annotation\Scanner\ClassFileInfo
which inherits from Symfony\Component\Finder\SplFileInfo
but
additionally offers access to the annotations of the class.