Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do you recommend for a PHP Coding Standards tool/system/program? [closed]

I'm working on a PHP project with several developers, each who has their own style. The styles differ significantly, and can make the code really hard to read, and everyone is in agreement that we need to standardize our style.

The issue I'm having is that I can't find any good program or system to help enforce standards for PHP. I've used a number of programs in the past for C++ and Java, and I'm a huge checkstyle fan, but I can't find anything so elegant for PHP.

What program, tool, or system would you recommend to help developers adhere to a common set of PHP coding standards? Additionally, it would be great if the solution also handled PHP embedded in XHTML, but that is not a requirement.

like image 421
David Smith Avatar asked Apr 14 '09 13:04

David Smith


People also ask

What are coding standards in software engineering?

What are Coding Standards? Think of coding standards as a set of rules, techniques, and best practices to create cleaner, more readable, more efficient code with minimal errors. They offer a uniform format by which software engineers can use to build sophisticated and highly functional code.

How do I run PHP CodeSniffer?

In the Settings dialog, go to Editor > Inspections. From the inspections screen, expand the PHP | Quality tools node and enable “PHP CodeSniffer validation”. In the configuration pane that is now enabled, select “Custom” from the “Coding standard” dropdown, locate the ruleset configuration ( phpcs.


2 Answers

PHP_CodeSniffer seems like a great tool. A project I was affiliated with used the Zend Framework coding standard as a basis for our own, and we looked into using it.

However, our deadline did not allow much leeway for experimenting with new tools, so we never got into using it past initial testing.

like image 149
Jukka Dahlbom Avatar answered Oct 01 '22 15:10

Jukka Dahlbom


I used in the past phpCodeBeautifier. It does not have lots of options, but it gets the job done to certain point and helps keeping standard code.

It's run from command line and, provided your IDE supports external formatters, you could integrate with that, or create a script to run on all your files.

Alternatively, if you use Eclipse or you don't but plan to run this occasionally, you could use Eclipse with its PHP plugin. You can re-format code inside folders with just a couple of clicks.

like image 34
Seb Avatar answered Oct 01 '22 13:10

Seb