Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
TV4ELP657yLogfile and Xdebug help to speed debugging up realy good.
I remember having echo $someVar after every few lines to debug when i started out... -
I have not used xdebug in forever.
Write short classes and methods, with good names. Don't use unnecessary intermediate variables. Use a library or write a class for collections so map/reduce/filter/etc is easy.
Use php >7.1. Use composer, conform to PSR-4/0 class naming and PSR-2 code style. Limit the amount of code outside of class methods, and limit the amount of unnamespaced php files.
Typehint all parameters. Fuck docblocks, fuck mixed, use proper signatures. Typehint all return types as well, and make every function return a single, pure and predictable type.
Don't throw exceptions if it's not absolutely necessary, instead return optionals or even monad wrappers so you're forced to directly handle them upon use.
Avoid dirty PHP tricks such as magic calls, reflection and traits as much as possible, unless you feel confident you can safely isolate and test the dirtiness.
And most importantly, write unit tests for any new class you create, and spend at least an hour a week refactoring or writing tests to cover old code. -
ZwoRmi747y@bittersweet you did provide the best advices I've ever seen here ! I'm gonna share that, thanks !
PHP feels
undefined