Documentation for Xtra Framework
By: Ali Irawan
Tags: Github, PHP, Documentation, Xtra, Heroku

When writing your own framework, you will need a documentation.

Thanks to phpDoc for the great tools.

Here’s what I do:

First, Download the PHAR version from phpDoc, download it as phpDocumentor.phar

Then, I put in my root project xtra

I need to put the phpDocumentor.phar to be ignored, I don’t want it goes to my repository

https://github.com/ali-irawan/xtra/blob/master/.gitignore

Notice that I already added a line “phpDocumentor.phar”

composer.phar

/vendor/



# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control

# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file

composer.lock

.DS_Store

.idea

/node_modules/

package-lock.json

.sass-cache/

phpDocumentor.phar

/docs/

/CACHE_DIR/

Run the phpDocumentor using this command on terminal

php phpDocumentor.phar -d src -t docs --template="responsive-twig" --cache-folder CACHE_DIR

-d src means, the phpDocumentor should see on the folder src

-t is specifying the output folder, you can anywhere you like, for example docs (already ignored too)

the --template is optional, it for the look & feel, i am using “responsive-twig”

last one specifying the --cache-folder, this is just used when generating docs

See the results:



Initializing parser .. OK

Parsing files

Parsing /home/sts/git/xtra/src/helpers/helpers.php

Parsing /home/sts/git/xtra/src/helpers/xtra_functions.php

Parsing /home/sts/git/xtra/src/Controllers/HomeController.php

Parsing /home/sts/git/xtra/src/Controllers/RegisterController.php

Parsing /home/sts/git/xtra/src/Controllers/LoginController.php

Parsing /home/sts/git/xtra/src/config/xtra-framework.php

Parsing /home/sts/git/xtra/src/Util/ValidatorUtil.php

Parsing /home/sts/git/xtra/src/Core/XtraException.php

Parsing /home/sts/git/xtra/src/Core/Errors/AuthenticationException.php

Parsing /home/sts/git/xtra/src/Core/Errors/FeatureNotImplementedException.php

Parsing /home/sts/git/xtra/src/Core/XtraFrameworkProvider.php

Parsing /home/sts/git/xtra/src/Core/Modular/Menu.php

Parsing /home/sts/git/xtra/src/Core/Modular/MenuContext.php

Parsing /home/sts/git/xtra/src/Core/FeatureImplementCheck.php

Parsing /home/sts/git/xtra/src/Core/XtraFrameworkModuleProvider.php

Parsing /home/sts/git/xtra/src/Logics/Common/XtraRegistration.php

Parsing /home/sts/git/xtra/src/Logics/Common/DefaultXtraRegistration.php

Parsing /home/sts/git/xtra/src/Logics/Auth/XtraAuthentication.php

Parsing /home/sts/git/xtra/src/Logics/Auth/DefaultXtraAuthentication.php

Parsing /home/sts/git/xtra/src/web/routes/common.php

Parsing /home/sts/git/xtra/src/web/define.php

Storing cache in "/home/sts/git/xtra/CACHE_DIR" .. OK

Load cache .. 0.002s

Preparing template "responsive-twig" .. 0.003s

Preparing 14 transformations .. 0.000s

Build "elements" index .. 0.000s

Replace textual FQCNs with object aliases .. 0.001s

Resolve

Enriches inline example tags with their sources .. 0.000s

Build "packages" index .. 0.000s

Build "namespaces" index and add namespaces to "elements" .. 0.000s

Collect all markers embedded in tags .. 0.000s

Transform analyzed project into artifacts ..

Applying 14 transformations

Initialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"

Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig"

Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"

Execute transformation using writer "FileIo"

Execute transformation using writer "FileIo"

Execute transformation using writer "FileIo"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "twig"

Execute transformation using writer "Graph"

0.255s

Analyze results and write report to log .. 0.000s Collecting files .. OKInitializing parser .. OKParsing filesParsing /home/sts/git/xtra/src/helpers/helpers.phpParsing /home/sts/git/xtra/src/helpers/xtra_functions.phpParsing /home/sts/git/xtra/src/Controllers/HomeController.phpParsing /home/sts/git/xtra/src/Controllers/RegisterController.phpParsing /home/sts/git/xtra/src/Controllers/LoginController.phpParsing /home/sts/git/xtra/src/config/xtra-framework.phpParsing /home/sts/git/xtra/src/Util/ValidatorUtil.phpParsing /home/sts/git/xtra/src/Core/XtraException.phpParsing /home/sts/git/xtra/src/Core/Errors/AuthenticationException.phpParsing /home/sts/git/xtra/src/Core/Errors/FeatureNotImplementedException.phpParsing /home/sts/git/xtra/src/Core/XtraFrameworkProvider.phpParsing /home/sts/git/xtra/src/Core/Modular/Menu.phpParsing /home/sts/git/xtra/src/Core/Modular/MenuContext.phpParsing /home/sts/git/xtra/src/Core/FeatureImplementCheck.phpParsing /home/sts/git/xtra/src/Core/XtraFrameworkModuleProvider.phpParsing /home/sts/git/xtra/src/Logics/Common/XtraRegistration.phpParsing /home/sts/git/xtra/src/Logics/Common/DefaultXtraRegistration.phpParsing /home/sts/git/xtra/src/Logics/Auth/XtraAuthentication.phpParsing /home/sts/git/xtra/src/Logics/Auth/DefaultXtraAuthentication.phpParsing /home/sts/git/xtra/src/web/routes/common.phpParsing /home/sts/git/xtra/src/web/define.phpStoring cache in "/home/sts/git/xtra/CACHE_DIR" .. OKLoad cache .. 0.002sPreparing template "responsive-twig" .. 0.003sPreparing 14 transformations .. 0.000sBuild "elements" index .. 0.000sReplace textual FQCNs with object aliases .. 0.001sResolve @link and @see tags in descriptions .. 0.000sEnriches inline example tags with their sources .. 0.000sBuild "packages" index .. 0.000sBuild "namespaces" index and add namespaces to "elements" .. 0.000sCollect all markers embedded in tags .. 0.000sTransform analyzed project into artifacts ..Applying 14 transformationsInitialize writer "phpDocumentor\Plugin\Core\Transformer\Writer\FileIo"Initialize writer "phpDocumentor\Plugin\Twig\Writer\Twig"Initialize writer "phpDocumentor\Plugin\Graphs\Writer\Graph"Execute transformation using writer "FileIo"Execute transformation using writer "FileIo"Execute transformation using writer "FileIo"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "twig"Execute transformation using writer "Graph"0.255sAnalyze results and write report to log .. 0.000s

Then I put some server.js for server static files using nodeJs

Installing node modules

npm install connect serve-static

server.js

var connect = require('connect');

var serveStatic = require('serve-static');

connect().use(serveStatic(__dirname)).listen(10000, function(){

console.log('Server running on 10000...');

});

Then run

node server.js

Server running on 10000...

Run on my browser at http://localhost:10000

Is it cool ? There are also a lot of alternative tools. But I found phpDoc is already quite good.

I put the generate docs in github

By connecting Github to Heroku we can easily have this