Created
April 1, 2014 16:50
-
-
Save VEnis/9918124 to your computer and use it in GitHub Desktop.
phpdoc usage example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Assume we are in directory named "demo" and we have php: >=5.3.3 installed | |
Download phpdoc from http://phpdoc.org/phpDocumentor.phar | |
1) Simple example of the source generation workflow | |
Go to the packagist to the page of some package. For example https://packagist.org/packages/monolog/monolog | |
Look of the package source code location at the top of the page. It will say "Source: https://github.com/Seldaek/monolog/tree/master" (99% it will be github) | |
Go to this page and download source code archive. In our example it will be https://github.com/Seldaek/monolog/archive/master.zip | |
Extract this archive to the some directory, for example in "source" | |
Run phpdoc to generate html documentation in the output directory named "doc" | |
php phpDocumentor.phar -d source -t doc --template responsive-twig | |
2) Better solution | |
All is the same, but run phpdoc as | |
php phpDocumentor.phar -d source -t doc --template xml | |
This will produce single xml file which will contain whole structure (classes, their properties, methods, docs etc) | |
Example of the file is http://pastebin.com/QttrrrDY | |
3) Potential problems | |
Currently a lot of php libraries from packagist has tests included and they I think must not be included to the generated code. | |
So best solution will be after downloading and extracting content of the package check file "composer.json" in the root of the extracted package and process it's section "autoload" according to composer documentation "https://getcomposer.org/doc/04-schema.md#autoload" like: | |
For each section under "autoload": | |
- if section is "psr-4" or "psr-0" then it will contain map of "name" to "directory" pairs and only those directories must be included in generation. | |
For example "monolog" contains: | |
"autoload": { | |
"psr-4": {"Monolog\\": "src/Monolog"} | |
}, | |
so only directory "src/Monolog" must be included | |
- if section is "classmap" of "files" then it contains list of files and directories and only they must be included | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually it can be simpler.
php composer.phar archive --format=zip monolog/monolog [version]
Version format can be found here: https://getcomposer.org/doc/01-basic-usage.md#package-versions