---
title: "Understanding All Relations Between Classes, Interfaces, Traits, and Enums in PHP"
url: https://www.exakat.io/understanding-all-relations-between-classes-interfaces-traits-and-enums-in-php/
date: 2025-09-15
modified: 2025-09-21
author: "dams"
description: "Understanding Relationships Between Classes, Interfaces, Traits, and Enums in PHP Modern PHP offers four major code structures — classes, interfaces, traits, and enums — each with its own purpose and..."
categories:
  - "Code auditing"
tags:
  - "knowledge"
  - "php"
image: https://www.exakat.io/wp-content/uploads/2025/09/stairs.320.jpg
word_count: 330
---

# Understanding All Relations Between Classes, Interfaces, Traits, and Enums in PHP

# Understanding Relationships Between Classes, Interfaces, Traits, and Enums in PHP

Modern PHP offers four major code structures — **classes**, **interfaces**, **traits**, and **enums** — each with its own purpose and rules. But the real power of PHP comes from how these structures can **interact with each other**. This page gathers all relations between classes in PHP.

If you’ve ever wondered *“Can an enum use a trait?”* or *“Can a trait implement an interface?”*, the answer lies in PHP’s keywords: `extends`, `implements`, and `use`. These keywords define the legal relationships between the building blocks of your code.

To make this crystal clear, here’s a matrix showing **who can interact with whom** — and with which keyword.

| Can interact with… | **  class  ** | ** interface** | **    trait    ** | **  enum  ** |
| -------------------- | ---------------- | --------------- | ---------------------- | --------------- |
| [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class.ini.html) | ✅ | ✅ | ✅ | ❌ |
| [**interface**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ❌ | ✅ | ❌ | ❌ |
| [**trait**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ | ❌ | [✅](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ |
| [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) | ❌ | ✅ | ✅ | ❌ |

## Longer version (with links)

| Can interact with… | **class** | **interface** | **trait** | **enum** |
| -------------------- | --------- | ------------- | --------- | -------- |
| [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class.ini.html) | ✅ [**extends**](https://php-dictionary.readthedocs.io/en/latest/dictionary/implements.ini.html) one [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class)(single inheritance); Or [**composition**](https://php-dictionary.readthedocs.io/en/latest/dictionary/composition.ini.html) | ✅ [**extends**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) one or multiple [**interface**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ✅ [**use**](https://php-dictionary.readthedocs.io/en/latest/dictionary/use.ini.html) one or multiple [**traits**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ Cannot [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) an [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) (no inheritance), can only call its cases |
| [**interface**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ❌ Cannot [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) a [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class.ini.html) | ✅ [**extends**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) one or multiple [**interfaces**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ❌ Cannot [**use**](https://php-dictionary.readthedocs.io/en/latest/dictionary/use.ini.html) a [**trait**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ Cannot [**implement**](https://php-dictionary.readthedocs.io/en/latest/dictionary/implements.ini.html) or [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) an [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) |
| [**trait**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ Cannot [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) a [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class.ini.html) | ❌ Cannot [**implement**](https://php-dictionary.readthedocs.io/en/latest/dictionary/implements.ini.html) an [**interface**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ✅ [**use**](https://php-dictionary.readthedocs.io/en/latest/dictionary/use.ini.html)other [**traits**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html)inside a [trait](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ Cannot [**use**](https://php-dictionary.readthedocs.io/en/latest/dictionary/use.ini.html) an [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) |
| [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) | ❌ Cannot [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) a [**class**](https://php-dictionary.readthedocs.io/en/latest/dictionary/class.ini.html) | ✅ [**implements**](https://php-dictionary.readthedocs.io/en/latest/dictionary/implements.ini.html)one or multiple [**interfaces**](https://php-dictionary.readthedocs.io/en/latest/dictionary/interface.ini.html) | ✅ [**use**](https://php-dictionary.readthedocs.io/en/latest/dictionary/use.ini.html) one or multiple [**traits**](https://php-dictionary.readthedocs.io/en/latest/dictionary/trait.ini.html) | ❌ Cannot [**extend**](https://php-dictionary.readthedocs.io/en/latest/dictionary/extends.ini.html) another [**enum**](https://php-dictionary.readthedocs.io/en/latest/dictionary/enum.ini.html) |

## Key Takeaways

-
**Classes** are the most versatile: they can extend a class, implement interfaces, and use traits.

-
**Interfaces** can only extend other interfaces — nothing else.

-
**Traits** are like reusable code fragments. They can be used in classes and enums and even use other traits, but cannot stand alone.

-
**Enums** (introduced in PHP 8.1) behave like special classes: they cannot extend other classes or enums, but they can implement interfaces and use traits.