Two components offering the same functionality, required by different dependencies

Posted by kander on Programmers See other posts from Programmers or by kander
Published on 2013-08-02T14:04:42Z Indexed on 2013/08/02 16:02 UTC
Read the original article Hit count: 228

I'm building an application in PHP, using Zend Framework 1 and Doctrine2 as the ORM layer. All is going well. Now, I happened to notice that both ZF1 and Doctrine2 come with, and rely on, their own caching implementation. I've evaluated both, and while each has its own pro's and cons, neither of them stand out as superior to the other for my simple needs. Both libraries also seem to be written against their respective interfaces, not their implementations.

Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers - each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

I'm trying to determine what the best way forward is, and would welcome any insights you may be able to offer.

What I've thought up so far are four options:

  1. Do nothing, accept that two classes offering caching functionality are present.
  2. Create a Facade class to stick Zend's interface onto Doctrine's caching implementation.
  3. Option 2, the other way around - create a Facade to map Doctrine's interface on a Zend Framework backend.
  4. Use multiple-interface-inheritance to create one interface to rule them all, and pray that there aren't any overlaps (ie: if both have a "save" method, they'll need to accept params in the same order due to PHP's lack of proper polymorphism).

What option is best, or is there a "None of the above" variant that I'm not aware of?

© Programmers or respective owner

Related posts about php

Related posts about architecture