Welcome to ManageWP.org

Register to share, discuss and vote for the best WordPress stories every day, find new ideas and inspiration for your business and network with other members of the WordPress community. Join the #1 WordPress news community!

×

PHP Standards Recommendations

php-fig.org | Nov. 26, 2015 | 1 min read

If you code PHP you should know about the PSRs

12 votes   Flag
Zdravko Ćurić

Hey, first time commenting here.
If Wordpress has it's own PHP standards (10up.github.io/Engineering-Best-Practices/ and www.wptherightway.org/en/) how much is worth to use PSRs in WP development anyway if most of community do not apply these recommendations and they stick with WP coding standards (of which are most consider "bad practices" by modern PHP communities)?

Thanks!

Reply
Tom Harrigan

Note: these are the WordPress PHP coding standards: make.wordpress.org/core/handbook/best-practices/coding-standards/php/

Most of this set of standards is in regards to code formatting. The PSR's encompass a whole lot more than that, in general I think it best to follow PSR unless it conflicts with a WordPress standard, in which case the WordPress standard wins out.

To answer your question as to how much it's worth using the PSR's in WP development, I think that depends on the type of work you're doing. In environments at scale or with large development teams, following these standards leads to a higher rate of interchangeability of developers, allowing new devs to be on-boarded more easily, and lends itself to creating more maintainable projects. It's never a bad thing to follow the standards.

Also, congrats on your first comment :)

Reply
Zdravko Ćurić

Thanks for the answer!

I forgot the HANDBOOK :)

Personally, I think PSRs are the way to go. But as you said, maybe for the sake of WP environment, WP standard should have the first work.

I do work in large development team and we recently started enforcing PHP-FIG recommendations and TDD and we all benefit from that.

My hope is that one day WP will be open to more PSRs and move to modern PHP development.

Reply