YOUR (CODING) STANDARDS
MATTER
ABOUT ME
Software Engineer
PHP since 11 years
CI
CleanCode
DevOps
TDD
Shipping
Bullet points
WORKING FOR
ResearchGate gives science back to the people who make it happen.
We help researchers build reputation and accelerate scientific
progress.
On their terms.
GET IN TOUCH
stackoverflow:
Twitter: @_ _edorian
G+ / Xing: Volker Dusch
IRC (freenode): edorian
Mail: php@wallbash.com
WHY I AM HERE TODAY
SO WHAT IS THIS TALK ABOUT?
PHP!
CODING GUIDELINES!
THE TOOLS
PHP MESSDETECTOR
Complexity, long term maintainability, keeps you honest when
designing
PHP CODE SNIFFER
Code formatting, simple coding errors, helps you stay consistent in a
team
PURPOSE (IMHO)
PHPMD is for naming, size, complexity and all the hard to change
things
PHPCS is for whitespace and all the things that are easy to fix
HOW TO MAKE USE OF THEM
Configure rules that match the way you are working!
It's easier than it feels!
WHAT ABOUT STANDARDS?
PHPMD: Use all the rules, they are reasonable. Configure them later
PHPCS: Use PSR2. Replace things if they don't work for your team
INSTALLING
{
"require": {
"squizlabs/php_codesniffer": "*",
"phpmd/phpmd": "*"
},
"config": {
"bin-dir": "/usr/local/bin/"
}
}
DEMO
Let's create ruleset files for both of the tools :)
http://edorian.github.io/php-coding-standard-generator/#phpmd
COMMANDS USED
Use most of PHPMDs rules:
Use your custom ruleset:
Use PSR2 with PHPCS:
Use your own PHPCS rules:
phpmd source text codesize,unusedcode,naming,design
phpmd source text phpmd.xml
phpcs --standard=PSR2 source/
phpcs --standard=phpcs.xml source/
CONTINUOUS INTEGRATION
Real world usage along a projects lifecylce
Pretty graphs in Jenkins!
Fail your travis ci build on phpcs errors?
Fail your travis ci build on phpmd errors???
THANK YOU!
QUESTIONS?
GET IN TOUCH
stackoverflow:
Twitter: @_ _edorian
G+ / Xing: Volker Dusch
IRC (freenode): edorian
Mail: php@wallbash.com
Your (coding) standards matter

Your (coding) standards matter