12.3 Adapter and Factory
A factory is a pattern with which you can—in somewhat simplified terms—create different object instances without specifying the classes in advance. The instance is created by a method, not by a constructor.
Another pattern is the adapter. This is usually a class with a fixed interface that can be used for communication. The adapter in turn forwards requests to that interface to underlying objects, which may have a completely different interface. This occurs in Laminas, for example, when working with databases. The Laminas\Db\Adapter\Adapter class exists for this purpose; the specific database to be used is specified by configuration. The generic adapter works with a whole range of compatible database systems. Our ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access