PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1
CHAPTER 16 ■ GENERATING DOCUMENTATION WITH PHPDOCUMENTOR

property). It also includes special keywords called tags. Tags are defined using the at sign (@) and may be
associated with arguments. So the following DocBlock placed at the top of a class tells phpDocumentor
the package to which it belongs:


/**



  • @package command
    */


If I add this comment to every class in my project (with the appropriate package name, of course),
phpDocumentor will organize our classes for us. You can see phpDocumentor output that includes
packages in Figure 16–3.


Figure 16–3. Documentation output that recognizes the @package tag


In Figure 16–3, notice that packages have been added to the navigation (top-right corner). In
addition to the default megaquiz package I defined as a command line switch, I can now click command or
quiztools. Because I am currently examining classes in the command package, the links that form the left-
hand navigation list only those classes.
Generally, packages in documentation will mirror your directory structure. So the command package
maps to a command directory. That isn’t necessary, however. A third-party developer may wish to create a
Command class that is part of the command package but lives in her own directory, for example. So the
@package tag makes you take responsibility for associating classes with packages, but it also affords you
flexibility that would not be available by using the file system to guess at package names.

Free download pdf