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

Integration with Laravel 5.1 Framework #235

Open gbvaz opened 8 years ago

gbvaz commented 8 years ago

Hello! I've been using PHP Reports for some days as an independent install, just to see how it all works, and I think itis right tool for me!

The only problem is that I'm not so sure how can I integrate it with my system that runs on Laravel (5.1) framework. I've been looking into other issues here on github, and I've found a couple of similar questions, one for Zend framework (Issue #213) and another for CakePHP 3.x (Issue #204). Should that approach work for Laravel too? Did anyone got it working in the first place?

Any help is appreciated! Thanks!

lrojas94 commented 7 years ago

I'm also interested in this... Did you manage to do it @gbvaz ?

gbvaz commented 7 years ago

@lrojas94 I ended up switching to Reportico they have an integration with laravel, and it's really easy to use http://www.reportico.org/laravel/public/

lrojas94 commented 7 years ago

@gbvaz I just finished integrating it with laravel 5.3 :). it was not extremely hard. In case you're still interested:

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class PHPReportController extends Controller { public function __construct() { require_once(base_path('phpreports/vendor/autoload.php')); require_once(base_path('phpreports/lib/PhpReports/PhpReports.php')); }

public function index() {
    \PhpReports::listReports();
}

public function reportListJson() {
    return response()
            ->json(\PhpReports::getReportListJSON());
}

public function report(Request $request) {
    \PhpReports::displayReport($request->input('report'),'html');
}

public function reportWithFormat(Request $request, $format) {
    \PhpReports::displayReport($request->input('report'),$format);
}

}


* Re-Route all routes present in **php-reports/index.php**
* Since PHP Reports uses php5, you should also check the PR #220 to make it work with PHP7 if needed.
* Re-structure paths on PHPReports.php so that they use **base_path()** function. This happens, as explained in #204 because of relative paths. Note that you should do the same in the config file for the paths to all needed folders.

I got it up and running :) I tried reportico before... but since I wanted control over the code, sadly, I had to let it go... This one seem to have a better code base and is better organized.
gbvaz commented 7 years ago

@lrojas94 Great tutorial, thanks for sharing! I'll give it a try and let you know. :+1: