Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
28 lines (20 sloc) 1.18 KB
title subTitle currentMenu
Coding style
PHP Best practices
php-coding-style

Respect PSR-1 and PSR-2

Beginner ###Rule

PHP now has a coding style guide shared by many projects. Its name is PSR-2. You should follow it.

###Explanation

At TheCodingMachine, most of us hate spaces. We prefer tabs. So why not ask for developers to use tabs? Because PSR-2 says we should use spaces. We might not like everything in PSR-2 but at least, it is a shared standard. It means that if you follow it, your code will follow the same standard as the vast majority of projects out there.

Oh... one very important thing! Do not spend any time learning PSR-2. This is useless! Instead, use a code formatting tool that will do the work for you!

Use PHP-CS-Fixer. It will do all the work for you. Run PHP-CS-Fixer before any commit you plan to do.

Tip: install PHP-CS-Fixer globally using Composer. You will be able to use it on any project, anywhere in the project tree.