DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Coding
  3. Languages
  4. There's no reason not to switch to DocBlox

There's no reason not to switch to DocBlox

Giorgio Sironi user avatar by
Giorgio Sironi
·
Aug. 30, 11 · Interview
Like (0)
Save
Tweet
Share
11.08K Views

Join the DZone community and get the full member experience.

Join For Free
Alessandro Nadalin signals these three options for Api documentation generation, the process of extracting Api informations on classes and methods from a folder full of source code:
  • phpDocumentor is based on PHP 4, and not developed anymore (the last release was in 2008). It's the good old phpdoc command.
  • doxygen is a mature choice that supports many languages, and it's not written in PHP (with some hacks it supports even JavaScript.)
  • DocBlox is a PHP 5.3 compliant, actively developed tool. It's already used in Zend Framework and Agavi. It was ceated by Mike Van Riel, a Dutch PHP developer whom I met at the last DPC where he held a DocBlox talk at the Uncon.

A PHP tool, faster than doxygen in implementing new features, and actively developed: these are the factors that made me choose DocBlox as my new default Api documentation mean.

Installation

The requirements for DocBlox are PHP 5.3 with the XSL extension enabled. Additional extensions will be required for additional functionalities such as graphs.

sudo apt-get install php5-xsl   # in Debian-based Linux distributions
sudo pear channel-discover pear.docblox-project.org
sudo pear channel-discover pear.michelf.com    # some dependencies
sudo pear install docblox/DocBlox-beta

At the time of this writing, DocBlox 0.13.3 will be installed by these commands.

Features (from the docs)

Performance is one key advantage of DocBlox. It parses Zend Framework (version 1.1 in this benchmark) in less than 90 seconds; it has low memory usage (< 50 MB) and implements incremental parsing by only accessing changed files since the last execution. On a small-sized project, it's blazingly fast.

DocBlox has PHP 5.3 support: namespaces are recognized; scopes and other PHP 5 constructs are a default.

The user interface produced by DocBlox contains a JavaScript search, and allows for independent theming and templating: multiple skins and multiple layouts. It has a support for a custom Writer implementations to transform the XML parsed structure in something other than HTML.

Demo

DocBlox own's demo shows how it has an user experience more advanced and current than phpDocumentor's old earthli template.

You can also see an example on real code, by taking a look at Zend Framework's Api documentation.

Trying it out

mkdir apidocs
docblox run -d . -t apidocs

For the basic use case, that's it: parse the current folder by selecting only the PHP files and produce a result in the apidocs/ folder.

You can save the command in a Phing target, or introduce a docblox.dist.xml file to store the configuration:

<?xml version="1.0" encoding="UTF-8" ?>
<docblox>
    <parser>
        <target>apidocs</target>
    </parser>
    <transformer>
        <target>apidocs</target>
    </transformer>
    <files>
        <directory>.</directory>
    </files>
</docblox>

With this file in place, you can just run docblox in the folder containing it.

User interface

The default theme, which by the way will be the one used by the majority of the projects, is usable enough and good-looking. It shows:

  • a list of classes and files on the left.
  • C/I icons of different colors for classes and interfaces.
  • p/m icons for property and methods.
  • Circles of different colors (green to red) for scope private to public.

JavaScript navigation works even when not served from an HTTP server but just as a folder loaded in the browser. However JavaScript search requires the Api docs to be loaded via HTTP from a PHP-capable web server (a virtual host in your local Apache configuration will do it.)

Wthout any docblocks present, DocBlox list methods organized by logic and physical location (class and file), their names and parameters.

With docblocks present, all metadata are extracted: fields are listed with type and default value; methods with their entire prototype (parameters with type and default if applicable, and return type of the method itself):

The interface has foldable descriptions for methods in order to save space; the same classes for a package are listed in a single page loaded in the frame and are navigated via anchors, speeding up loading time. However I see from Zend Framework documentation that this behavior can be modified to break up classes in different pages.

Conclusions

There's no reason not to choose docblox as the default for your project and abandoning phpDocumentor. It is still a PHP-dedicated tool, written in PHP and distributed with an open source MIT license.

The docblocks tags supported are exactly the same, so the only thing that changes is the command for generation; the support is even improved as namespaces are correctly identified. Installation is available via PEAR and easier as for phpDocumentor, both for your development machines and for your Continuous Integration server.

DocBlox on GitHub

DocBlox's documentation (it's documentation on the tool, not on docblock's syntax.)

PHP

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How To Handle Secrets in Docker
  • Custom Validators in Quarkus
  • Cloud Performance Engineering
  • Testing Repository Adapters With Hexagonal Architecture

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: