What is the Adapter pattern in PHP?
Answer
The Adapter pattern allows incompatible interfaces to work together by wrapping one class with another that translates calls from the expected interface to the wrapped class's interface. It is a structural pattern that acts as a bridge between two incompatible interfaces. Example: you have third-party payment library StripePayment with a charge() method, but your application expects a PaymentGateway interface with a process() method. Create StripeAdapter implements PaymentGateway that wraps StripePayment and delegates process() to charge(). Now your application works with any gateway as long as you have an adapter. This is how PSR-7 adapters allow different frameworks to work with the same HTTP message format, and how logging adapters (Monolog) provide PSR-3 compliance for various logging backends.
Previous
What is the difference between abstract methods and interface methods in PHP?
Next
What is the Facade pattern in PHP/Laravel?