php-reports icon indicating copy to clipboard operation
php-reports copied to clipboard

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

Open dawoodjee opened this issue 9 years ago • 4 comments

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

dawoodjee avatar Sep 08 '15 15:09 dawoodjee

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.

ripperkhan avatar Nov 26 '15 18:11 ripperkhan

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

danayasin avatar Dec 14 '15 07:12 danayasin

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.

ripperkhan avatar Dec 14 '15 16:12 ripperkhan

@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.

aa411853 avatar May 14 '16 12:05 aa411853