Use a trait only for small, genuinely cross-cutting behavior: ~~~php trait HasTimestamps { private DateTimeImmutable $updatedAt; public function touch(): void { $this->updatedAt = new DateTimeImmutable(); } } final class User { use HasTimestamps; } ~~~ Keep traits focused and lightweight; do not use them to hide unrelated state or business responsibilities.
Installs into .claude/skills of the current project.
Are you the author of Php Best Practices?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/hoangnguyen0403-php-best-practices-ddcbe02c)
Use a trait only for small, genuinely cross-cutting behavior:
~~~php
trait HasTimestamps
{
private DateTimeImmutable $updatedAt;
public function touch(): void
{
$this->updatedAt = new DateTimeImmutable();
}
}
final class User
{
use HasTimestamps;
}
~~~
Keep traits focused and lightweight; do not use them to hide unrelated state or business responsibilities.