70
Comments
  • 0
    @starkfire man i feel you
  • 0
    Logfile and Xdebug help to speed debugging up realy good.

    I remember having echo $someVar after every few lines to debug when i started out...
  • 2
    If you replace PHP with programming in general I agree :)
  • 1
    only happens when it is others code
  • 6
    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.
  • 0
    That's why I hate PHP and instead of that I use Javascript(Node.js), Python or Ruby.
  • 1
    @bittersweet you did provide the best advices I've ever seen here ! I'm gonna share that, thanks !
Add Comment