Glossary

Trait

A trait is a code-reuse mechanism for languages with single inheritance. A trait contains real methods and properties that are "inserted" into a class with the use keyword. PHP has supported traits since version 5.4.

When useful

When several unrelated classes need the same behaviour, but a shared base class is not appropriate. For example, Timestampable, SoftDeletable, HasSlug — behaviours that have no logical connection to each other.

Pitfalls