Glossary

Interface

An interface is a contract describing what a class must be able to do, but not how. A class that implements an interface must implement all of its methods. An interface has no implementation — only method signatures.

Why it matters

Interfaces let you write code that depends on an abstraction rather than a concrete class. Any implementation that satisfies the contract can be substituted — the foundation of Dependency Injection and unit testing.

Example

interface Logger {
  public function log(string $message): void;
}

class FileLogger implements Logger { ... }
class NullLogger implements Logger { ... }

Interface vs Abstract Class