jdorn / php-reports

A PHP framework for displaying reports from any data source, including SQL and MongoDB
http://jdorn.github.com/php-reports
GNU Lesser General Public License v3.0
477 stars 235 forks source link

How to integrate with other frameworks (e.g CakePHP 3.x) #204

Open dawoodjee opened 9 years ago

dawoodjee commented 9 years ago

Hi,

I've been looking for a PHP Reporting Framework to use in my CakePHP 3.x Application. Is there a quick guide for integration out there or could you please give me quick tips to get me started off as i'm hacking away at your docs and my code.?

CakePHP requires that third-party code be placed in app_name/vendors directory, which is what your this framework also does. I see that php-reports also does some URL rewriting, and other things that CakePHP already handles and this has me concerned about compatibility.

Any and all help on this will be greatly appreciated. Thanks

ripperkhan commented 8 years ago

Providing this as is, I do not have real any experience with cakephp, but I have done this similarly with codeigniter and the joomla framework.

Copy php-reports to the vendor directory.

In your controller use this to import the php-reports

public function construct() { parent::construct(); require_once(ROOT . 'vendor' . DS . 'php-reports' . DS . 'vendor' . DS . 'autoload.php'); require_once(ROOT . 'vendor' . DS . 'php-reports' . DS . 'lib' . DS . 'PhpReports' . DS . 'PhpReports.php');

}

Then you can take whats in the methods that you see in the index.php in php-reports and wrap them with your controller methods.

Like this below

// list reports public function index(){ PhpReports::listReports(); }

public function report($format) { if(isset($format)) {
PhpReports::displayReport($_REQUEST['report'],$format); } else { PhpReports::displayReport($_REQUEST['report'],'html'); } }

This should be enough to get you started in the right direction.

danayasin commented 8 years ago

I did the same steps but this message was displayed Cannot find config file because the pathes in the PhprReports.php are relative

ripperkhan commented 8 years ago

You may need to edit the PhpReports.php file.

you'll have to make a few changes to some of the reference paths.

  1. Edit path for config file
  2. Edit template_dirs
  3. edit the report_list_url under the render method
  4. edit the paths in the buildLoaderCache method for the classes/local and /lib

That should be it to get it to work.

aa411853 commented 8 years ago

@adam-je I'm looking for something similar for a cakephp 3 app. Were you able to integrate this reporting plugin with cakephp? If not what was your solution?

Appreciate any advice you can share.