Developer News: Improving XOOPS Code: PHP CodeSniffer

Posted by: MambaOn 2009/8/31 20:00:00 7545 reads
Obviously, everybody has a different coding styles, but in order to make it easier for everybody to read it, we need to follow certain "Coding Standards".

The current XOOPS Coding Standards are here

But how to make sure that everybody does it correctly, and there are no mistakes?

Here comes the PHP CodeSniffer, which we'll use going forward before each release.

We would also like every developer contributing code to XOOPS (be it to Core, or as individual modules) to check his/her work before submitting to SVN!

1) Install CodeSniffer:

If you're using WAMP, here are instructions to install PEAR, and then CodeSniffer:

http://www.webeks.net/programming/wamp-pear-installation.html

NOTE: there are currently problems with installing PEAR on PHP 5.3:

2) Set Zend as your default:

phpcs --config-set default_standard Zend


3) Run CodeSniffer

See:

http://pear.php.net/manual/en/package.php.php-codesniffer.usage.php

I didn't compare the Zend standard with ours, but since our is based on Zend, then they should be very similar. If there are differences, we'll create our own customized standard file, based on our "XOOPS Coding Standards", as described here:

http://clockwerx.blogspot.com/2008/06/how-to-customise-phpcodesniffer.html

As we are moving forward it's important that we start using more and more tools that will help us with improving our code and our development process.

As next, I am looking at "PHP Under Control"

Has anybody any experience with it?

To discuss this topic, please visit this thread