Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter for PHP_CodeSniffer (coding convention coding standard coding guidelines)


I would like to share my implementation of CodeIgniter coding guidelines for PHP_CodeSniffer with you, member of the CodeIgniter's community.
I put my work on GitHub [1] few days ago.

CodeIgniter's style guide [2] is not fully implemented yet, but it may save some time to start from this partial implementation.

Feel free to share your ideas and criticisms :-)

Hope that helps.

[1] https://github.com/thomas-ernest/CodeIgn...odeSniffer
[2] http://ellislab.com/codeigniter/user-gui...guide.html

[eluser]Eric Barnes[/eluser]
I haven't looked at implementing this yet but this is awesome. I was searching for just this a few weeks back and thought I was going to have to modify Kohanas Smile

Thanks for sharing!

Thank you for your work, that's what I was looking for !

You're welcome.

I released the code a few days before CodeIgniter 2.0.0 was released. However, CodeIgniter 2.0.0 came with a new Guide Style. I haven't had time to improve code to erase the few slightly differences brought with the new coding convention. The current implementation is based on CodeIgniter 1.7.3 Guide Style. I hope having time to work on it soon and make it compatible with CodeIgniter 2.0.0 coding standard.


Hi there,
I'm quite new to both php/eclipse-pdt and codeigniter. We just started a project with these tools though, and since our policy recommends using tools like this, I would love to get a guide for how to use it?
Is codesniffer a plugin of its own or part of eclipse-pdt?


Hello Stefan,

PHP_CodeSniffer is available as a pear package http://pear.php.net/package/PHP_CodeSniffer/redirected .

I'm not used developing with Eclipse-PDT. However, I know that there is a Eclipse plug-in for PHP_CodeSniffer : http://www.phpsrc.org/projects/pti-php-c...ffer/wiki/ . I don't know, if this plugin is integrated in Eclipse-PDT.

To setup the CI coding standard in PHP_CodeSniffer, you will have to duplicate the file in the right place along PHP_CodeSniffer sources. Something like <my path to PHP_CS>/Standards/

If you're new to (most of) all these things, the better would be for you to get in touch with somebody or to be prepared to spend a loooot of time (to find documentation, tutorials or how-tos). Nonetheless, if you find something interesting, please write it down here, on this thread.

Good luck.

[eluser]Lars Germ[/eluser]
Is the codesniffer standard for CodeIgniter still in development? I send you a pull request on github, because you forgot to define a default target in the build.xml. I added the line in the xml.

And to change the "phpcs.dir" you can pass it as argument in the CL.
just type:
ant -Dphpcs.dir="path/to/Codesniffer/"

I've made some changes to the sniffs provided by Thomas. I got a bunch of errors on most CI files that I really wanted to get rid of:

1. PEAR's check for a file doc comment didn't allow any non white space between the PHP opening tag and the file doc comment. I've changed that so that code on the same line as the PHP opening tag is ignored. This means that the "if ( ! defined('BASEPATH')) ..." statement can sit right after the PHP opening tag without causing a warning.

2. Thomas' rules would forbid using multi line comments (/* ... */) anywhere unless they are doc block style comments. While this is correct according to the CI style guide, the guide also suggests that the end of file comments should use the multi line style comments for the end of file comments. My changes allows comments beginning with "/* Location:" or "/* End of file " specifically.

I've forked Thomas project on Github to this URL https://github.com/eriktorsner/CodeIgnit...niffer-ETO

Hopefully, I can convince Thomas to include my changes in his repo, but until then, I need to have it on github for my own purposes (build automaton). Feel free to use it and/or fork it.


Theme © iAndrew 2016 - Forum software by © MyBB