koolreport/laravel
Composer 安装命令:
composer require koolreport/laravel
包简介
Allow to use KoolReport seamlessly in Laravel
关键字:
README 文档
README
Without doubt, Laravel is the most favorite PHP Framework in the world. It is easy to learn, fast and powerful with full capability for any web application.
Since we created KoolReport we received many questions like "How to use KoolReport in Laravel?". The answer is KoolReport was designed to work with any PHP Frameworks and Laravel is one of them. The setting to make them work together is simple but we want to make things simpler.
Laravel package is an add-on extension to make KoolReport work seamlessly in Laravel Framework environment. By adding package, report created with KoolReport will recorgnize Laravel databases automatically. Furthermore, KoolReport's widgets will be configured assets path and url so that all are working without requiring any further set-up effort from you. All with a simple line of code:
use \koolreport\laravel\Friendship;
While Laravel is PHP Framework for general purpose, KoolReport only focus on reporting, data processing, charts and graphs. KoolReport will power Laravel report capability to the max. For fun comparison, Laravel with KoolReport is like Thanos with Mind Stone and this package is like the glove to connect them. Laravel is a powerful framework and KoolReport will make it better.
Requirement
- KoolReport >= 2.75.0
- Laravel >= 4.2
Installation
By downloading .zip file
- Download
- Unzip the zip file
- Copy the folder
laravelintokoolreportfolder so that look like below
koolreport ├── core ├── laravel
By composer
composer require koolreport/laravel
Documentation
Step-by-step tutorial
Step 1: Create report and claim friendship with Laravel
- First, you create folder
Reportsinside Laravel'sappfolder - Inside Reports folder, create two files
MyReport.phpandMyReport.view.php - Adding
use \koolreport\laravel\Friendshipto your report like following
MyReport.php
<?php
namespace App\Reports;
class MyReport extends \koolreport\KoolReport
{
use \koolreport\laravel\Friendship;
// By adding above statement, you have claim the friendship between two frameworks
// As a result, this report will be able to accessed all databases of Laravel
// There are no need to define the settings() function anymore
// while you can do so if you have other datasources rather than those
// defined in Laravel.
function setup()
{
// Let say, you have "sale_database" is defined in Laravel's database settings.
// Now you can use that database without any futher setitngs.
$this->src("sale_database")
->query("SELECT * FROM offices")
->pipe($this->dataStore("offices"));
}
}
MyReport.view.php
<?php
use \koolreport\widgets\koolphp\Table;
?>
<html>
<head>
<title>My Report</title>
</head>
<body>
<h1>It works</h1>
<?php
Table::create([
"dataSource"=>$this->dataStore("offices")
]);
?>
</body>
</html>
Step 2: Run report and display report
Now you have MyReport ready, in order to get report display inside Laravel, you will create MyReport's object in controller and pass that object to the view to render.
HomeController.php
<?php
namespace App\Http\Controllers;
use App\Reports\MyReport;
class HomeController extends Controller
{
public function __contruct()
{
$this->middleware("guest");
}
public function index()
{
$report = new MyReport;
$report->run();
return view("report",["report"=>$report]);
}
}
report.blade.php
<?php $report->render(); ?>
Other notes
Auto-generated assets
Laravel packages will automatically create a folder name koolreport_assets inside Laravel's public folder in order to hold the report resources such as Javascript files or CSS file.
Other datasources other than Laravel's default
If you have another datasources rather than Laravel's datasources, feel free to add them in settings() function as you normally do. For example, in below example code, we will have anoher csv source:
class MyReport extends \koolreport\KoolReport
{
use \koolreport\laravel\Friendship;
function settings()
{
return array(
"dataSources"=>array(
"csv_source"=>array(
"class"=>'\koolreport\datasources\CSVDataSource',
'filePath'=>dirname(__FILE__)."\mycsvdata.csv",
)
)
);
}
}
Customize assets folder
By default, adding Friendship will configure assets path and url for report automatically. But in some cases that you would like to set your own location, you can do:
class MyReport extends \koolreport\KoolReport
{
function settings()
{
return array(
"assets"=>array(
"path"=>"../../public/resources/kool"
"url"=>"resources/kool"
)
);
}
}
The path can be ralative path from the report to the assets folder or absolute path to assets folder.
The url is the browser url to access the assets folder.
Support
Please use our forum if you need support, by this way other people can benefit as well. If the support request need privacy, you may send email to us at support@koolreport.com.
koolreport/laravel 适用场景与选型建议
koolreport/laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 274.44k 次下载、GitHub Stars 达 18, 最近一次更新时间为 2019 年 05 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Data Report」 「Laravel Report」 「Reporting Tools」 「KooLReport Laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 koolreport/laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 koolreport/laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 koolreport/laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
Data provider for yii2
A CakePHP behavior to validate foreign keys
Common interface for interacting with data in objects and arrays.
统计信息
- 总下载量: 274.44k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 32
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-05-09