A library that provides a Simple, Lazy, Fast & Lightweight Annotation for php classes

v1.1.0 2022-10-08 09:42 UTC


Latest Version Software License Workflow Status Code Maintainability Coverage Status Quality Score Sponsor development of this project

biurad/php-annotations is an annotations and attribute reader for PHP 7.2+ created by Divine Niiquaye. This library provides a Simple, Lazy, Fast & Lightweight Doctrine Annotations and PHP 8 Attribute reader for your project.

📦 Installation & Basic Usage

This project requires PHP 7.2 or higher. The recommended way to install, is via Composer. Simply run:

$ composer require biurad/annotations

Let's say you working on a few projects and you need annotations support for each. With this library we make your work easier, all you need is a instance of Biurad\Annotations\ListenerInterface and an annotated class for finding annotations or attributes.

To know more about how to use this library, try going through the tests directory and find out how to integrate this library into your project.

example of usage:

use Biurad\Annotations\AnnotationLoader;
use Spiral\Attributes\AnnotationReader;
use Spiral\Attributes\AttributeReader;
use Spiral\Attributes\Composite\MergeReader;

// The doctrine annotation reader requires doctrine/annotations library
$doctrine = new AnnotationReader();

// With spiral/attributes library, we can use PHP 8 attributes in PHP 7.2 +
$attribute = new AttributeReader();

// Create a new annotation loader from readers ...
$annotation = new AnnotationLoader(new MergeReader([$doctrine, $attribute]));

$annotation->listener(...); // Add your implemented Annotation listeners

$annotation->resource(...); // Add a class/function string, class file, or directory

$listeners = $annotation->load(); // Compile once, then load cached ...

// To use a collector you implemented into your instance of `Biurad\Annotations\ListenerInterface`
foreach ($listeners as $collector) {
    // You can fetch the required $collector from here.

NB: If you are on PHP 8 and wishes to use attributes only, please avoid using spiral/attributes package for best performance contributing to why this library is not shipped with spiral/attributes package.

📓 Documentation

For in-depth documentation before using this library. Full documentation on advanced usage, configuration, and customization can be found at

⏫ Upgrading

Information on how to upgrade to newer versions of this library can be found in the UPGRADE.

🏷️ Changelog

SemVer is followed closely. Minor and patch releases should not introduce breaking changes to the codebase; See CHANGELOG for more information on what has changed recently.

Any classes or methods marked @internal are not intended for use outside of this library and are subject to breaking changes at any time, so please avoid using them.

🛠️ Maintenance & Support

When a new major version is released (1.0, 2.0, etc), the previous one (0.19.x) will receive bug fixes for at least 3 months and security updates for 6 months after that new release comes out.

(This policy may change in the future and exceptions may be made on a case-by-case basis.)

Professional support, including notification of new releases and security updates, is available at Biurad Commits.

👷‍♀️ Contributing

To report a security vulnerability, please use the Biurad Security. We will coordinate the fix and eventually commit the solution in this project.

Contributions to this library are welcome, especially ones that:

  • Improve usability or flexibility without compromising our ability to adhere to ???.
  • Optimize performance
  • Fix issues with adhering to ???.
  • ???.

Please see CONTRIBUTING for additional details.

🧪 Testing

$ composer test

This will tests biurad/php-annotations will run against PHP 7.2 version or higher.

👥 Credits & Acknowledgements

🙌 Sponsors

Are you interested in sponsoring development of this project? Reach out and support us on Patreon or see for a list of ways to contribute.

📄 License

biurad/php-annotations is licensed under the BSD-3 license. See the LICENSE file for more details.

🏛️ Governance

This project is primarily maintained by Divine Niiquaye Ibok. Members of the Biurad Lap Leadership Team may occasionally assist with some of these duties.

🗺️ Who Uses It?

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us an email or message mentioning this library. We publish all received request's at

Check out the other cool things people are doing with biurad/php-annotations: