markuszeller / php-annotations
Simple tool for parsing annotations
Installs: 235
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/markuszeller/php-annotations
Requires
- php: >=7.1
This package is auto-updated.
Last update: 2025-12-05 09:00:04 UTC
README
This class helps reading annotations.
Features
- reads from a string
- reads from a file
- supports multiline annotation values
- auto trims values
Note
Reads only annotations from DocComments included in /** [...] */.
Look into that double asterisk.
Usage
Initialise an Annotation object
require_once '../vendor/autoload.php';
use markuszeller\Annotations\Reader;
$reader = new Reader();
Put some data into the annotation reader instance
-
by a string
$cssString = file_get_contents('./template.css'); $reader->loadFromString($cssString); -
by file
if($reader->loadFromFile("./example.css") === false) { exit("Error loading file"); }
Get all the annotations as an associative array
$annotationArray = $reader->getAnnotations();
Get a single annotation by name
$title = $reader->getAnnotation('title');