Follow

I'm just throwing a question out there: When coding in PHP (or any language, really), do you adhere to any coding standards? Do you "optimize" your code? Or do you just keep everything as is as long as it works?

· · Web · 3 · 0 · 1

@hxii I try to keep in mind that I will come back to the code later and have to figure out what it does.

I recommend the book Clean Code by Robert C. Martin

@stephen thanks! I was just worried when opening the code to the public :)

@hxii I try to keep it dry no matter the language. I also try to not dry it too much if it requires a lot of back and forth or complicated workaround, or even too much knowledge for someone else to operate. So basically, dry until it crates more problems than it solves?

@hxii I do a lot of #WordPress work and prefer to adhere to their coding standards when working on a WP project.

Using them encourages me to document my code, which I'd otherwise be pretty bad about.

@boogah @hxii This, and I try to do the same with Laravel projects—same reasoning, different coding standards. I use PHPCS inside VS Code and have been playing around a bit with github.com/FriendsOfPHP/PHP-CS.

@jan @boogah Yeah I use PHPCS as well, but went from using the WordPress standard to PSR-1. Thing is, I'm still trying to figure out what is more comfortable for me and how important is adhering to a standard in smaller projects.

Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.