koolreport/blade 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

koolreport/blade

最新稳定版本:1.0.2

Composer 安装命令:

composer require koolreport/blade

包简介

Allow KoolReport to use blade template engine to render view

README 文档

README

Overview

If you have used Laravel and fell in love with Blade template engine then you may use this love template engine with KoolReport. Starting from version 4.0.0, KoolReport supports other template engines rather than just its own template view file.

So by using blade template engine, you can utilize the power of template inheritance such as creating common layout for your report.

Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your report.

Installation

By downloading .zip file

  1. Download
  2. Unzip the zip file
  3. Copy the folder blade into koolreport folder so that look like below
koolreport
├── core
├── blade

By composer

composer require koolreport/blade

Get started

Step 1: First you should create two folders, first is views to hold the views of your reports, secondly is cache folder for blade to generate cache file.

project/
├── reports/
│   └── MyReport.php
├── views/
│   └── myreport.blade.php
├── cache/

Step 2: Next, in your MyReport.php you initiate blade template like this:

require_once "../../koolreport/core/autoload.php";

class MyReport extends \koolreport\KoolReport
{
    use \koolreport\blade\Engine;
    
    protected function bladeInit()
    {
        $viewsFolder = __DIR__."/../views";
        $cacheFolder = __DIR__."/../cache";
        $blade = new \Jenssegers\Blade\Blade($viewsFolder, $cacheFolder);
        return $blade;
    }
    ...

}

Step 3: Create report's view content. In your myreport.blade.php you can do:

<html>
<head>
    <title>MyReport</title>
</head>
<body>
    <?php
    \koolreport\widgets\koolphp\Table::create(array(
        "dataSource"=>$report->dataStore("result"),
    ));
    ?>
</body>
</html>

Important Note: You need to use $report variable to refer to the report class, not $this as you do when use default Koolreport view file.

Step 4: To make the report run and render, you do:

//index.php

require_once "MyReport.php";

$report = new MyReport;
$report->run()->render("myreport"); // You need to specify the view you want to render

Now your report will run and then use myreport.blade.php to render the view of report.

Congrat!

Resources

  1. Full documentation
  2. Examples & Demonstration

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.

统计信息

  • 总下载量: 52.62k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-06-01