PHP Docblock parser and generator. An API to read and write Docblocks.

Installs: 1 421

Dependents: 3

Stars: 9

Watchers: 2

Forks: 1

Language: PHP

v1.5 2015-09-18 14:16 UTC


DOI Build Status Scrutinizer Code Quality Code Coverage

PHP Docblock parser and generator. An API to read and write Docblocks.


Install via Composer:

    "require": {
        "gossi/docblock": "~1"

And inject the Composer autoloader into your source code:

require_once 'path/to/vendor/autoload.php';


1. Generate a Docblock instance

a) Simple:

use gossi\docblock\Docblock;

$docblock = new Docblock();

b) Create from string:

use gossi\docblock\Docblock;

$docblock = new Docblock('/**
 * Short Description.
 * Long Description.
 * @author gossi

c) Create from reflection:

use gossi\docblock\Docblock;

$docblock = new Docblock(new \ReflectionClass('MyClass'));

2. Manipulate tags

Get the tags:

$tags = $docblock->getTags();

Get tags by name:

$tags = $docblock->getTags('author');

Append a tag:

use gossi\docblock\tags\AuthorTag;

$author = new AuthorTag();

or with fluent API:

use gossi\docblock\tags\AuthorTag;


Check tag existence:


3. Get back the string

Call toString():


or if you are in a write-context, the magical __toString() will take care of it:

echo $docblock;


Feel free to fork and submit a pull request (don't forget the tests) and I am happy to merge.



Version 1.2 - November, 4th 2014

  • Renamed DocBlock to Docblock
  • Added License Tag
  • Added Link Tag

Version 1.1 - May, 28th 2014

  • Added tag sorting for DocBlock::toString();

Version 1.0.1 - May, 28th 2014

  • Don't wordwrap long lines anymore. Fixing fluent interface for AbstractTag::setDescription();

Version 1.0 - May, 28th 2014

  • Initial release