Jun 11, 2014 CodeIgniter-for-PHPCodeSniffer. Provides sniffs for PHPCodeSniffer 1.3.0 and above to check CodeIgniter coding standard. A bit of story PHPCodeSniffer. PHPCodeSniffer is a PHP5 script that tokenises and 'sniffs' PHP, JavaScript and CSS files to detect violations of a defined coding standard. It is an essential development tool that ensures your code remains clean and consistent. Improve your PHP coding productivity with the free compact. He builds web applications, is a standards and accessibility. Then CodeIgniter syntax rules.
Provides sniffs for PHP_CodeSniffer 1.3.0 and above to check CodeIgniter coding standard.
A bit of story
PHP_CodeSniffer
PHP_CodeSniffer is a PHP5 script that tokenises and 'sniffs' PHP, JavaScript and CSS files to detect violations of a defined coding standard.
It is an essential development tool that ensures your code remains clean and consistent. It can also help prevent some common semantic errors made by developers.
By default sniffs for a few coding convetions are provided like PEAR, Zend, PHPCS and Squiz. CodeIgniter-for-PHP_CodeSniffer is aimed at adding support for CodeIgniter coding convention.
CodeIgniter coding standard
CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.
CodeIgniter is developed by EllisLab. The compagny follows some specific coding rules for their developments and for CodeIgniter especially.
Based on PHP_CodeSniffer CodeIgniter-for-PHP_CodeSniffer helps to validate most of the rules in CodeIgniter coding standard.
Installation
There is an Apache Ant script at the root of the repository. It targets standard Linux environment like Ubuntu with PHP_CodeSniffer 1.3.0 or above installed via PEAR. It requires PHP (in its 5th version).
![Pdf Pdf](/uploads/1/2/5/8/125850606/238611832.jpg)
Just go to the root of the project and type
ant
to set up CodeIgniter-for-PHP_CodeSniffer.If you have CodeSniffer installed in another directory than '/usr/share/php/PHP/CodeSniffer/' than you can pass the right directoryas argument to ant. Just type ant -Dphpcs.dir='/path/to/CodeSniffer/'
.Check that it is installed type
phpcs -i
you should see a list of installed standards.Then you can go to you project folder and run
phpcs --standard=CodeIgniter my-file-or-my-directory.php
.If you work on a Windows platform or for any reason, it is easy to edit the installation script. You just need to change the property
phpcs.dir
in build.xml
to point toward the directory containing PHP_CodeSniffer.Install
Download and install Atom Editor:
Install required SO packages:
Code Formatters
atom-beautify uses JS Beautify by default.
For PHP, atom-beautify follow coding standards from php-codesniffer.
Install php-codesniffer:
After, you can see the default Standards with the command
phpcs -i
. The output will be like:CodeIgniter has your own Codeing Standard and the CodeIgniter-for-PHP_CodeSniffer follow this rules.
We can install the CodeIgniter Standard as follow:
Now, lets put the src folder in the correct path:
Now, the output of
phpcs -i
will be:If do you wnat, you can change the PHPCBF Standard to
CodeIgniter
.TODO: Is possible setup PHPCBF Standard by project-manager file?
![Php Php](/uploads/1/2/5/8/125850606/633241187.gif)
Linters
The Awesome
PHP Integrator is a powerfull project that provides code analysis and utilities for PHP projects.
PHP Integrator uses composer to install the core and you need install the correct version corresponding to the php-integrator-base version.
PHP Integrator uses the project-manager to activate resources based by project.
Lets install the Atom packages:
CodeIgniter
When you works on a CodeIgniter 3 project you can download this file https://raw.githubusercontent.com/natanfelles/codeigniter-phpstorm/master/phpstorm.php inside your project root.
After go to Atom and open the menu Packages > Project Manager > Edit Projects and configure your project like it:
This tip will do PHP Integrator do not read the
Controller.php
and Model.php
from the system folder, then it will use all the @property
from phpstorm.php
file.You can read more about it in Code Completion for CodeIgniter in phpStorm and here Excluding Folders From Indexing.
On CodeIgniter 4 you do not need do this config. PHP Integrator will works natively well.
Extras
Some extra packages that I like: