Skip to content

Commit 0fc751f

Browse files
committed
Update readme
1 parent 3f69d9d commit 0fc751f

1 file changed

Lines changed: 90 additions & 11 deletions

File tree

README.md

Lines changed: 90 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,120 @@
1-
# PlatesPhp for KoolReport
1+
# PlatesPHP
22

3-
This package make KoolReport able to use PlatesPhp template engine to generate view content.
3+
## Overview
44

5-
# Installation
5+
Starting from version 4.0.0, KoolReport supports other template engines rather than just its own template view file and `PlatesPhp` is one of them.
66

7-
Run composer command
7+
Plates is a native PHP template system that’s fast, easy to use and easy to extend. It’s inspired by the excellent Twig template engine and strives to bring modern template language functionality to native PHP templates. Plates is designed for developers who prefer to use native PHP templates over compiled template languages, such as Twig or Smarty.
8+
9+
#### Highlight
10+
11+
* Native PHP templates, no new syntax to learn
12+
* Plates is a template system, not a template language
13+
* Plates encourages the use of existing PHP functions
14+
* Increase code reuse with template layouts and inheritance
15+
* Template folders for grouping templates into namespaces
16+
* Data sharing across templates
17+
* Preassign data to specific templates
18+
* Built-in escaping helpers
19+
* Easy to extend using functions and extensions
20+
* Framework-agnostic, will work with any project
21+
* Decoupled design makes templates easy to test
22+
* Composer ready and PSR-2 compliant
23+
24+
You may read more information about Plates PHP in [here](https://platesphp.com/).
25+
26+
## Installation
27+
28+
#### By downloading .zip file
29+
30+
1. [Download](https://www.koolreport.com/packages/platesphp)
31+
2. Unzip the zip file
32+
3. Copy the folder `platesphp` into `koolreport` folder so that look like below
33+
34+
```bash
35+
koolreport
36+
├── core
37+
├── platesphp
38+
```
39+
40+
#### By composer
841

942
```
1043
composer require koolreport\platesphp
1144
```
1245

13-
# Guide
46+
## Get started
47+
48+
__Step 1:__ First create a folder to hold the views
1449

15-
1. Add `use \koolreport\platesphp\Engine;` to your report
16-
2. Add protected method `platesInit()` and return the plates object
50+
```bash
51+
project/
52+
├── reports/
53+
│ └── MyReport.php
54+
├── views/
55+
│ └── myreport.phtml
56+
```
1757

18-
# Example
58+
__Step 2:__ Next, in your `MyReport.php` you initiate platesphp template like this:
1959

2060
```
61+
require_once "../../koolreport/core/autoload.php";
62+
2163
class MyReport extends \koolreport\KoolReport
2264
{
2365
use \koolreport\platesphp\Engine;
66+
2467
protected function platesInit()
2568
{
26-
return League\Plates\Engine::create(dirname(__FILE__).'/templates');
69+
return League\Plates\Engine::create(dirname(__FILE__).'/../views');
2770
}
71+
...
2872
2973
}
3074
```
3175

32-
Supposed you have a view for report named `myreport.phtml` inside `templates` folder, you can render your report like this:
76+
__Step 3:__ Create report's view content. In your `myreport.phtml` you can do:
77+
78+
```
79+
<html>
80+
<head>
81+
<title>MyReport</title>
82+
</head>
83+
<body>
84+
<?php
85+
\koolreport\widgets\koolphp\Table::create(array(
86+
"dataSource"=>$report->dataStore("result"),
87+
));
88+
?>
89+
</body>
90+
</html>
91+
```
92+
93+
__*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.
94+
95+
__Step 4:__ To make the report run and render, you do:
96+
3397

3498
```
99+
//index.php
100+
101+
require_once "MyReport.php";
102+
35103
$report = new MyReport;
36-
$report->run()->render("myreport");
104+
$report->run()->render("myreport"); // You need to specify the view you want to render
37105
```
38106

107+
Now your report will run and then use `myreport.phtml` to render the view of report.
108+
109+
__Congrat!__
110+
111+
112+
# Resources
113+
114+
1. [Full documentation](https://www.koolreport.com/docs/platesphp/overview/)
115+
2. [Examples & Demonstration](https://www.koolreport.com/examples)
116+
117+
39118
# Support
40119

41120
Please use [our forum](https://www.koolreport.com/forum/topics) 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](mailto:support@koolreport.com).

0 commit comments

Comments
 (0)