Scientific Linux で CodeIgniter-for-PHP_CodeSniffer を使う例を書きます。
RedHat系も同様の手順で大丈夫だと思います。
動作環境
動作環境は Scientific Linux release 6.0 です。
$ cat /etc/redhat-release Scientific Linux release 6.0 (Carbon)
インストール方法
pear から PHP_CodeSniffer をインストールします。
(pear の使い方はManual :: PEAR Manualをご覧下さい。)
$ sudo pear install PHP_CodeSniffer
github から CodeIgniter-for-PHP_CodeSniffer を git clone します。
$ cd
$ git clone git://github.com/thomas-ernest/CodeIgniter-for-PHP_CodeSniffer.git
PEAR の該当のディレクトリにコピーします。
$ sudo cp -Rv CodeIgniter-for-PHP_CodeSniffer/src /usr/share/pear/PHP/CodeSniffer/Standards/CodeIgniter
次のように CodeIgniter が表示されればインストール成功です。
$ phpcs -i
The installed coding standards are PEAR, MySource, PSR1, CodeIgniter, Zend, PSR2, PHPCS and Squiz
次のようにエイリアスを追加すれば便利です。
$ cat >> .bash_profile alias phpcsci='phpcs -v --standard=CodeIgniter --encoding=utf-8' $ source .bash_profile
使い方(テスト)
$ cat > test.php <?php echo 'test';
次に、test.php を文法チェックします。
$ phpcsci test.php Registering sniffs in CodeIgniter standard... DONE (34 sniffs registered) Creating file list... DONE (1 files in queue) Changing into directory /home/mukai Processing test.php [6 tokens in 2 lines]... DONE in < 1 second (3 errors, 0 warnings) FILE: /home/mukai/test.php -------------------------------------------------------------------------------- FOUND 3 ERROR(S) AFFECTING 1 LINE(S) -------------------------------------------------------------------------------- 2 | ERROR | Missing file doc comment 2 | ERROR | No comment block marks the end of file instead of the closing PHP | | tag. Please add a comment block containing only "End of file | | test.php". 2 | ERROR | Unable to find "/application/" in file path | | "/home/mukai/test.php". Please set your project's application | | root. --------------------------------------------------------------------------------
上記のようにメッセージが表示されればOKです。