I am writing an MVC framework. I have a folder full of library classes, each are self contained, and could be ripped out of the framework and used by themselves. The only problem is that a few of these libraries (benchmarking, unit testing) display HTML to report results.

I am wondering, do I display this HTML in a view file, or hard code it into the class? If I use view files, these modules will no longer be able to be used by themselves, and will require the print_view() method found in another class. If I hard code this HTML into the library class however, the class becomes difficult to read, as well as makes it harder to modify the design aspects of the reports.

Any suggestions/thoughts?


A testing/benchmarking reporting tool should use its own output framework and not rely on that of the main site/application.

So, absolutely don't use your "print_view" method (as you call it) from the main site to output library analysis HTML (this would be a reverse/circular dependency), but absolutely do embed some kind of view/output engine into the libraries that provide output. You are correct to want to avoid embedding HTML into your benchmarking/testing libraries.

This embedded output engine could be:

  • Something quick and dirty (inside a function, extract template var array + include PHP template file)
  • A lightweight MVC framework
  • A copy of your website framework (though being different in purpose it's probably not ideal).
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.