Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
132 lines (94 sloc) 4.13 KB


Lithium QA can be used as library plugged into a Lithium application.

Code in the master branch should always be compatible with the most recent Lithium core. However sometimes changes have to be made rendering QA incompatible with older cores. In that case please choose a tagged version of QA. Please note that components of QA will try to interact with the VCS of the project you are checking. Only GIT is supported a such.


We'll first obtain a new Lithium application. Than register QA as a submodule into the applications libraries.

git clone git:// new
cd new
git submodule add git:// libraries/li3_qa

Now we make the application aware of the new library by adding the following line to config/bootstrap/libraries.php.


Finally we pull in all submodules in this case the application, its submodules (Lithium), li3_qa and li3_qa's submodules (phpca).

git submodule update --init --recursive

Syntax Command

Files can be syntax checked using the Syntax command which comes with the application. The command utilizes PHPca to check the syntax of PHP files against a set of rules. These rules are based upon the Lithium Coding Standards and the Lithium Code Documentation Standards.

The basic usage is:

li3 syntax [--metrics] [--blame] PATH

Here we are checking the whole file tree of our pet project:

li3 syntax /path/to/project

If you want to log the output to a file (and you're on *nix) this might come in handy:

li3 syntax /path/to/project 2>&1 | tee verify_project.log

Blame each failure and show metrics:

li3 syntax --metrics --blame /path/to/project

GIT Pre Commit Hook

This pre commit hook is based upon the example found in .git/hooks/pre-commit.sample. Copy the sample script to /path/to/project/.git/hooks/pre-commit and make it executable. Then, replace the code in the script with the code shown below and adjust the paths to Lithium QA and the li3 command.

cd /path/to/project
cp .git/hooks/pre-commit.sample .git/hooks/pre-commit
chmod a+x .git/hooks/pre-commit

Now add the following code to .git/hooks/pre-commit and adjust the LI3 value.



if git-rev-parse --verify HEAD >/dev/null 2>&1
    # Initial commit: diff against an empty tree object


for FILE in `git diff-index --cached --name-only --diff-filter=AM ${AGAINST}`
    cd $APP && $LI3 syntax ${PROJECT}/${FILE}
    test $? != 0 && EXIT_STATUS=1


Now when committing each file the syntax is checked. The commit is aborted if a check failed. If you don't want to have the hook run on commit pass the --no-verify option to git commit.

Covered Command

Allows for checking if classes in a given library (or project) all have corresponding tests according to the Lithium standard. Also prints out coverage percentage.

li3 covered /path/to/library

Will output something similar to the following.

has test |  95.00% | lithium\util\Collection
has test |  97.98% | lithium\util\Inflector
has test | 100.00% | lithium\util\collection\Filters
has test |     n/a | lithium\test\Controller
has test |  95.24% | lithium\test\Dispatcher
 no test |     n/a | lithium\test\Filter

Documented Command

Allows for the checking of the presence of Lithium file headers, class documenation, as well as method/param documentation.

li3 documented /path/to/library

Will output something similar to:

	line: 128	__construct() not documented.
	line: 135	_init() not documented.

	line: 1   No file header found.
	line: 10  Class Bar not documented.
	line: 18	$code not documented.