whatisgithub

What is annotations?

doctrine/annotations — explained in plain English

Analysis updated 2026-06-24

6,745PHPAudience · developerComplexity · 2/5LicenseSetup · moderate

In one sentence

A PHP library that reads special tags written in code comments and converts them into structured data, letting frameworks like Symfony configure routing and database mappings from those comments.

Mindmap

mindmap
  root((doctrine/annotations))
    What it does
      Parse PHP docblocks
      Extract annotation tags
    Typical use
      Route configuration
      ORM mappings
      Framework config
    Status
      Feature-complete
      Security fixes only
    Migration path
      PHP 8 native attributes
      No new features
    Origin
      From Doctrine Common
      Extracted for reuse
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Parse @Route or @ORM annotations in PHP docblocks so your framework can configure routing or database mappings directly from comments above each method.

USE CASE 2

Build a PHP library that lets users configure behavior through annotations in code comments rather than separate configuration files.

What is it built with?

PHP

How does it compare?

doctrine/annotationsaonez/kekasebastianbergmann/environment
Stars6,7456,7726,779
LanguagePHPPHPPHP
Setup difficultymoderateeasyeasy
Complexity2/51/51/5
Audiencedevelopergeneraldeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · moderate Time to first run · 30min

New projects should use PHP 8 native attributes instead, this library is in maintenance mode with no new features planned.

Use freely for any purpose including commercial use, keep the copyright notice.

So what is it?

Doctrine Annotations is a PHP library that reads special tags written inside code comments (called docblocks) and turns them into structured data that applications can act on. For example, a developer might write a tag like @Route("/homepage") in a comment above a function, and this library parses that tag so a web framework knows to connect that URL to that function. The idea is to put configuration directly alongside the code it describes rather than in separate files. The library was originally part of Doctrine Common, a set of shared utilities used across the Doctrine database toolkit for PHP. It was extracted into its own package so other projects could use the annotation parsing feature independently. The README includes an important note for anyone considering adopting this library: PHP 8 added native support for a similar concept called attributes, which accomplish the same goal through built-in language syntax rather than parsed comments. The Doctrine team considers this library feature-complete and recommends that new projects use PHP attributes instead. Libraries that currently depend on Doctrine Annotations are encouraged to add attribute-based alternatives for their users. For existing projects that already use it, the library will continue to receive security and bug fixes, but no new features are planned. Full documentation is on the Doctrine project website.

Copy-paste prompts

Prompt 1
I have a PHP class with Doctrine-style @Route annotations in its docblocks. Show me how to use Doctrine Annotations to read those annotations and extract the route paths.
Prompt 2
I'm migrating a PHP project from Doctrine Annotations to native PHP 8 attributes. Help me write equivalent attribute classes for my existing annotation classes.
Prompt 3
Using Doctrine Annotations, help me create a custom @Validate annotation that stores validation rules I can read at runtime in my PHP framework.

Frequently asked questions

What is annotations?

A PHP library that reads special tags written in code comments and converts them into structured data, letting frameworks like Symfony configure routing and database mappings from those comments.

What language is annotations written in?

Mainly PHP. The stack also includes PHP.

What license does annotations use?

Use freely for any purpose including commercial use, keep the copyright notice.

How hard is annotations to set up?

Setup difficulty is rated moderate, with roughly 30min to a first successful run.

Who is annotations for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.