PHPackages                             phramz/doctrine-annotation-scanner - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. phramz/doctrine-annotation-scanner

ActiveLibrary[Database &amp; ORM](/categories/database)

phramz/doctrine-annotation-scanner
==================================

library to scan files and folders for annotated classes using doctrine annotations

v1.0.1(12y ago)14136.7k↓41.3%51MITPHPPHP &gt;=5.3

Since Oct 25Pushed 9y ago1 watchersCompare

[ Source](https://github.com/phramz/doctrine-annotation-scanner)[ Packagist](https://packagist.org/packages/phramz/doctrine-annotation-scanner)[ Docs](https://github.com/phramz/doctrine-annotation-scanner)[ RSS](/packages/phramz-doctrine-annotation-scanner/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (1)

Annotation Scanner [![Build Status](https://camo.githubusercontent.com/e1a254aeb9eb7fdaa8efd81cc84a47fd809881a7d1c11ceaf020ca23e6e3719a/68747470733a2f2f7472617669732d63692e6f72672f706872616d7a2f646f637472696e652d616e6e6f746174696f6e2d7363616e6e65722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/phramz/doctrine-annotation-scanner)
========================================================================================================================================================================================================================================================================================================================================================

[](#annotation-scanner-)

Annotation Scanner is a library to scan files and folders for annotated classes using doctrine annotations.

Install
-------

[](#install)

It's easy if you use composer!

edit your `composer.json`

```
"require": {
    "phramz/doctrine-annotation-scanner": "dev-master"
}
```

or via command line

```
php composer.phar require phramz/doctrine-annotation-scanner

```

License
-------

[](#license)

This library is licensed under the MIT license. For further information see LICENSE file.

Known limitations
-----------------

[](#known-limitations)

Your code has to meet the following conditions to make this library work properly:

- Follow the [PSR-0](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) 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](http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html#registering-annotations) documentation for details.

Examples
--------

[](#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

[](#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](http://symfony.com/doc/current/components/finder.html) documentation.

```
