๐Ÿ”ฅ Weekly thread #07 of 2022

๐Ÿ”ฅ This week's code tips for Laravel developers

A weekly thread ๐Ÿงต

Use comments for explaining complex logic

6

๐Ÿ”ฅ Use comments for explaining complex logic

Use comments for explaining complex logic

Comments in code should be used with care. They should only be added when they add actual value to the programmer; which is why I style them in such a way that they "pop out", instead of them disappearing in the background.

Move tests to separate test suites

3

๐Ÿ”ฅ Move tests to separate test suites

Move tests to separate test suites

My Laravel tip of the day. If you're running slow tests that need to hit a third party API, you can break them out of your Features directory and put them in a dedicated test suite (e.g. External). Then you can run "phpunit --testsuite Feature", and your External tests won't run.

You can use traits inside PHP enums

2

๐Ÿ”ฅ You can use traits inside PHP enums

You can use traits inside PHP enums

A few days ago, I learned that PHP enums can use traits

It may seem like a massive anti-pattern, but it allows making enums actually awesome with this one trick ๐Ÿ”ฅ

We're writing a book, you can get it for free here.