PHPBuilder - PHP Extension Add-on Repository (PEAR) Page 4

RSS Twitter

PHP Extension Add-on Repository (PEAR) - Page 4

by: Sean Cazzell
July 30, 2000


Many modern languages have a built in documentation system which allows developers to embed documentation into their code. This makes keeping documentation up to date easier, and simple tools can be created to parse the documentation out of the code and create docs in formats such as HTML, XML, etc. PEAR has adopted Javadoc as its official inline documentation format. Development efforts are currently underway to write javadoc parsers in php, and provide "phpdoc" tools for php developers.
Writing PEAR Packages
To re-cap, here are the things you need to keep in mind when writing code that you intend to eventually submit to PEAR.
  • Packages should be named based on their functionality.
  • Classes have the same name as your package, but with slashes replaced with underscores.
  • Files containing php code should have the extension ".php".
  • You should never call die or exit from within your packages.
  • Instead, you should return an error to the caller, even if it's just a boolean value.
  • You should use get_cfg_var to determine if certain optional features are enabled.
  • You should use the <?php ... ?> code block tag syntax.
  • You should use HTTP_*_VARS instead of relying on global variables.
  • Global variables should be defined using the $GLOBAL array.


The following pages were using extensively in the writing of this document. Special credit must be given to Stig Bakken, who wrote the PEAR documentation which provided the bulk of the information in this document.

« Previous Page

Comment and Contribute

Your comment has been submitted and is pending approval.

Sean Cazzell



(Maximum characters: 1200). You have characters left.