PHPackages                             kartik-v/yii2-report - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. kartik-v/yii2-report

ActiveYii2-extension[PDF &amp; Document Generation](/categories/documents)

kartik-v/yii2-report
====================

A Yii2 component to generate beautiful formatted reports using MS Word Templates in PDF/DOC/DOCX format

83.1k↓66.7%2PHP

Since May 25Pushed 6y ago1 watchersCompare

[ Source](https://github.com/kartik-v/yii2-report)[ Packagist](https://packagist.org/packages/kartik-v/yii2-report)[ RSS](/packages/kartik-v-yii2-report/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [ ![Krajee Logo](https://camo.githubusercontent.com/4addfbb3869c3fc7d79befea4f06d9cf3655a686fb503df0da1d725859cfdef9/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f6b72616a65652d6c6f676f2d622e706e67) ](http://demos.krajee.com "Krajee Demos")
 yii2-report ---

 [ ![Donate](https://camo.githubusercontent.com/4af77d425ca202e55ab3d711b438e238ded194735bc345a019ac060e03e26227/687474703a2f2f6b617274696b2d762e6769746875622e696f2f626f6f7473747261702d66696c65696e7075742d73616d706c65732f73616d706c65732f646f6e6174652e706e67) ](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU "Donate via Paypal")
===============================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#------------------------yii2-report--------------------)

[![Latest Stable Version](https://camo.githubusercontent.com/d74e2c8083ca67b4ba5405593730f9477da2694495f089571942bacc6642f26c/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f762f737461626c65)](https://packagist.org/packages/kartik-v/yii2-report)[![Latest Unstable Version](https://camo.githubusercontent.com/d13c047596fb11e8f09c97ee9f2bae3e719af246261c9fa5e5ad1a825682ecbb/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f762f756e737461626c65)](https://packagist.org/packages/kartik-v/yii2-report)[![License](https://camo.githubusercontent.com/f59cd0fc85d1e25fd1bbd4c3fe66b57d92d11c3f6d3579520e4a7cb0cf69fab0/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f6c6963656e7365)](https://packagist.org/packages/kartik-v/yii2-report)[![Total Downloads](https://camo.githubusercontent.com/ca333a4b177ed0370b897137937db731885fb834c81a7cb80e84a9b80c58227e/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f646f776e6c6f616473)](https://packagist.org/packages/kartik-v/yii2-report)[![Monthly Downloads](https://camo.githubusercontent.com/dbc695bdb924914ee23a8115027a265bc6859d031cc6af1865e3c72040fee3bd/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f642f6d6f6e74686c79)](https://packagist.org/packages/kartik-v/yii2-report)[![Daily Downloads](https://camo.githubusercontent.com/3692681322d7f5ee6b9ef0fbf2954b6394df213c2639e5ebe7cf6af55328b94f/68747470733a2f2f706f7365722e707567782e6f72672f6b617274696b2d762f796969322d7265706f72742f642f6461696c79)](https://packagist.org/packages/kartik-v/yii2-report)

A Yii2 component to generate beautiful formatted reports using Microsoft Word Document Templates in PDF/DOC/DOCX format. The component uses the [PHP reports library API](https://www.php-reports.com/) to generate reports. PHP-Reports is a cloud based, interactive report engine which helps in generating well formatted PDF reports from Word / DOCX templates.

How to contribute via a pull request?
-------------------------------------

[](#how-to-contribute-via-a-pull-request)

Refer this [git workflow for contributors](.github/GIT-WORKFLOW.md).

Installation
------------

[](#installation)

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Pre-requisites
--------------

[](#pre-requisites)

> Note: Check the [composer.json](https://github.com/kartik-v/yii2-dropdown-x/blob/master/composer.json) for this extension's requirements and dependencies. You must set the `minimum-stability` to `dev` in the **composer.json** file in your application root folder before installation of this extension OR if your `minimum-stability` is set to any other value other than `dev`, then set the following in the require section of your composer.json file

```
kartik-v/yii2-report: "@dev"

```

Read this [web tip /wiki](http://webtips.krajee.com/setting-composer-minimum-stability-application/) on setting the `minimum-stability` settings for your application's composer.json.

Install
-------

[](#install)

Either run

```
$ php composer.phar require kartik-v/yii2-report "@dev"

```

or add

```
"kartik-v/yii2-report": "@dev"

```

to the `require` section of your `composer.json` file.

Usage
-----

[](#usage)

### Step 1: Getting API Key

[](#step-1-getting-api-key)

Create free account at  and get your free API Key.

### Step 2: Creating Your First Template

[](#step-2-creating-your-first-template)

To accelerate the process of creating your reports and applications, PHP Reports takes advantage of Microsoft Word's design capabilites. Simply create a Microsoft Word file and design your report.

### Step 3: Using Template Variables

[](#step-3-using-template-variables)

You can use template variables in your Microsoft Word template. Template variables take their name from the contents of their double curly braces and they can later be replaced with a concrete value.

All template variable names within a template string must be unique. Template variable names are case-insensitive.

[![Word Template Screenshot](https://camo.githubusercontent.com/97876a25b0fc8f9b43b8bca2c9cfbf8d8af04e14114ab87f9ba7435c0f210171/68747470733a2f2f7777772e7068702d7265706f7274732e636f6d2f696d616765732f7068702d7265706f7274732d7661726961626c65732e706e67)](https://camo.githubusercontent.com/97876a25b0fc8f9b43b8bca2c9cfbf8d8af04e14114ab87f9ba7435c0f210171/68747470733a2f2f7777772e7068702d7265706f7274732e636f6d2f696d616765732f7068702d7265706f7274732d7661726961626c65732e706e67)

### Step 4: Upload Your Template

[](#step-4-upload-your-template)

Save and upload your template at "Template Manager" section in . Remember the template identifier (`templateId`).

### Step 5: Setting up the `yii2-report` global component

[](#step-5-setting-up-the-yii2-report-global-component)

Setup the following component in the `components` section of your Yii2 application configuration file.

```
use kartik\report\Report;

// ...
'components' => [
    // setup Krajee Yii2 Report component
    'report' => [
        'class' => Report::classname(),
        'apiKey' => 'YOUR_PHP_REPORTS_API_KEY',
        // the following variables can be set to globally default your settings
        'templateId' => 1, // optional: the numeric identifier for your default global template
        'outputAction' => Report::ACTION_FORCE_DOWNLOAD, // or Report::ACTION_GET_DOWNLOAD_URL
        'outputFileType' => Report::OUTPUT_PDF, // or Report::OUTPUT_DOCX
        'outputFileName' => 'KrajeeReport.pdf', // a default file name if
        'defaultTemplateVariables' => [ // any default data you desire to always default
            'companyName' => 'Krajee.com'
        ]
    ]
]
```

### Step 6: Generating the report from the component

[](#step-6-generating-the-report-from-the-component)

```
use kartik\report\Report;

$report = Yii::$app->report;

// set your template identifier (override global defaults)
$report->templateId = 2;

// If you want to override the output file name, uncomment line below
// $report->outputFileName = 'My_Generated_Report.pdf';

// If you want to override the output file type, uncomment line below
// $report->outputFileType = Report::OUTPUT_DOCX;

// If you want to override the output file action, uncomment line below
// $report->outputFileAction = Report::ACTION_GET_DOWNLOAD_URL;

// Configure your report data. Each of the keys must match the template
// variables set in your MS Word template and each value will be the
// evaluated to replace the Word template variable. If the value is an
// array, it will treated as tabular data.
$report->templateVariables = [
    'client_name' => 'Murat Cileli',
    'address' => 'Kadikoy, Istanbul / Turkey',
    'date' => '10-Apr-2018',
    'phone' => '+1-800-3399622',
    'email' => 'admin@gmail.com',
    'notes' => 'Thank you for your purchase.',
    'quantities' => ['6', '3', '4'],
    'products' => ['Apple iPhone 5S', 'Samsung Galaxy S5', 'Office 365 License'],
    'prices' => ['490 USD', '399 USD', '199 USD'],
];

// lastly in your controller action download the generated report
return $report->generateReport();
```

### Step 7: Check your output report document

[](#step-7-check-your-output-report-document)

Your output should look something like below:

[![Output Document Screenshot](https://camo.githubusercontent.com/c7331b97235992f5c793c71c2891eee1bcda75d20b63f589c01d7bff5bdf0561/68747470733a2f2f7777772e7068702d7265706f7274732e636f6d2f696d616765732f7068702d7265706f7274732d76616c7565732e706e67)](https://camo.githubusercontent.com/c7331b97235992f5c793c71c2891eee1bcda75d20b63f589c01d7bff5bdf0561/68747470733a2f2f7777772e7068702d7265706f7274732e636f6d2f696d616765732f7068702d7265706f7274732d76616c7565732e706e67)

License
-------

[](#license)

**yii2-report** is released under the BSD-3-Clause License. See the bundled `LICENSE.md` for details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3592619?v=4)[Kartik Visweswaran](/maintainers/kartik-v)[@kartik-v](https://github.com/kartik-v)

---

Top Contributors

[![kartik-v](https://avatars.githubusercontent.com/u/3592619?v=4)](https://github.com/kartik-v "kartik-v (7 commits)")

### Embed Badge

![Health badge](/badges/kartik-v-yii2-report/health.svg)

```
[![Health](https://phpackages.com/badges/kartik-v-yii2-report/health.svg)](https://phpackages.com/packages/kartik-v-yii2-report)
```

###  Alternatives

[phpoffice/phpspreadsheet

PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine

13.9k293.5M1.3k](/packages/phpoffice-phpspreadsheet)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k32.1M102](/packages/spatie-browsershot)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[barryvdh/laravel-snappy

Snappy PDF/Image for Laravel

2.8k24.8M48](/packages/barryvdh-laravel-snappy)[openspout/openspout

PHP Library to read and write spreadsheet files (CSV, XLSX and ODS), in a fast and scalable way

1.1k57.6M131](/packages/openspout-openspout)[keboola/csv

Keboola CSV reader and writer

1451.8M21](/packages/keboola-csv)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
