I’m looking for recommendations on how to do some reporting in PHP. Specifically, I need PDF rendering and I would like to separate the presentation from my code as much as possible (templates of some sort?).
I’ve recently received a PHP4 code-base on the job and am in charge of upgrading to PHP5. The reports currently are created via TCPDF which are driven from HTML generated straight from PHP. The upgrade process is proving extremely challenging. I’m running into multiple problems with TCPDF where it will just go into an infinite loop and never return. Through some troubleshooting and forum posts, it appears we’re doing some stuff that TCPDF4 with PHP4 didn’t have a problem with but TCPDF5 and PHP5 does. Unfortunately, rather than error on whatever rules we’re breaking, I just get infinite hangs. Our in-house code could use some refactoring and I feel a re-write could mitigate many of these problems, however I’m not opposed to looking beyond TCPDF right now.
Our code also has a lot of the HTML generation mixed in with the rest of the reporting features. I would really like to separate this out so that little to no PHP code is required when editing or creating a report. I don’t need anything too fancy for the report. Needs to support basic data tables and multiple horizontal panes on a single tab. There are charts but they are currently generated by a separate package and just read directly as an image. Suggestions on the best way to re-do these reports? Thanks.
You can use PHP as a template engine, and than you can convert the HTML output to a PDF.
Here are the options for PHP templating:
render_template('template_name.php')or something like this.In your case, I think that you could write your own class for the handling of reports. Here just a simple sketch of the usage:
So, eventually you can use some of the simple ideas behind this simple sketch.
I hope that I understood your question correctly, and that I could help you with this answer.