ApiGen is a tool which generates documentation for your PHP projects, and it does that job really good and effectively. Most of the time I was using PHPDocumentator as documentation tool but now I have feeling it is a bit outdated and templates are not well designed if you ask me.

Here I will explain how to download, run and test ApiGen tool.

Installation

In order to install and run ApiGen you have to run PHP 5.4+ and that is only the requirement. Once you download .phar file, you are ready to go.  For those who don’t know what .phar file is, it is just an PHP application packed into single file. Using this file you can run PHP a application without any additional extracting. In order to run phar file, you have to install PHP. You can execute .phar files in command line using following command:

If your php is not globally available, then you have to provide a path where your php is installed. For example:

How to generate documentation

Once you have downloaded ApiGen .phar archive, you can generate documentation for your project by running the following command:

or short

Here are few concrete examples:

In first example, source files are in C:\wamp\www\yii2\basic\controllers and documentation will be saved in destination folder C:\Users\CodeEpicenter\Desktop\doc. Documentation title is “Documentation”.

In first example, source files are in C:\wamp\www\yii2\basic and documentation will be saved in destination folder C:\Users\CodeEpicenter\Desktop\doc. Documentation title is “Documentation”, but from source files I want to exclude folder called “vendor”. If you want to exclude more folders, then just write –exclude=folder1 –exclude=folder2 etc…

Results

ApiGen generates really nice and functional documentation, with powerful search functionality. It can recognize namespaces and will classify classes based on namespaces (check examples below).

It comes with two different templates, default and bootstrap. I prefer bootstrap template but if you don’t like any of these, you can develop your own template too.

To generate boostratp template just add –template-theme=bootstrap option to your command. Here is example:

Examples

Here are projects where ApiGen was used in order to generate documentation:

  • Cake PHP Framework  – http://api.cakephp.org/3.2/
  • Nette Framework – https://api.nette.org/2.3.8/
  • Doctrine Project – http://www.doctrine-project.org/api/orm/2.4/
  • Amazon – http://docs.aws.amazon.com/aws-sdk-php/v3/api/

Features

Here is a list of ApiGen features:

  • ApiGen is using their own TokenReflection library is used to describe the source code.
  • Detailed documentation of classes, functions and constants.
  • Highlighted source code.
  • Support of namespaces and packages with subpackages.
  • Experimental support of traits.
  • A page with trees of classes, interfaces, traits and exceptions.
  • A page with a list of deprecated elements.
  • A page with Todo tasks.
  • Link to download documentation as ZIP archive.
  • Checkstyle report of poorly documented elements.
  • Support for docblock templates.
  • Support for @inheritdoc.
  • Support for {@link}.
  • Active links in @see and @uses tags.
  • Documentation of used internal PHP classes.
  • Links to the start line in the highlighted source code for every described element.
  • List of direct and indirect known subclasses, implementers and users for every class/interface/trait/exception.
  • Check for a new version.
  • Google CSE support with suggest.
  • Google Analytics support.
  • Support for multiple/custom templates.
  • Sitemap and opensearch support.
  • Support for different charsets and line endings.
ApiGen - Generate Documentation for your PHP projecthttp://code-epicenter.com/wp-content/uploads/2016/02/ApiGen.pnghttp://code-epicenter.com/wp-content/uploads/2016/02/ApiGen-150x150.pngAmir DuranLibrariesPHPProgrammingApiGen,Documentation Generator,PHP,Tools
ApiGen is a tool which generates documentation for your PHP projects, and it does that job really good and effectively. Most of the time I was using PHPDocumentator as documentation tool but now I have feeling it is a bit outdated and templates are not well designed if you...