├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── README_PT.md ├── composer.json ├── composer.lock ├── config └── report.php ├── docker-compose.yml ├── examples ├── report-boleto.pdf ├── report1-html.php ├── report1-image.php ├── report1-pdf.php └── report1.html ├── phpunit.xml ├── src └── Report │ ├── Contracts │ ├── ExporterInterface.php │ └── ReportInterface.php │ ├── Exporters │ ├── AbstractExporter.php │ ├── AbstractPhantomExporter.php │ ├── HtmlExporter.php │ ├── ImageExporter.php │ └── PdfExporter.php │ ├── Laravel │ └── ReportServiceProvider.php │ └── Report.php └── tests └── Report ├── Exporters ├── AbstractExporterTest.php ├── AbstractPhantomExporterTest.php ├── HtmlExporterTest.php ├── ImageExporterTest.php └── PdfExporterTest.php └── ReportTest.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | /node_modules 3 | /docs 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | sudo: required 3 | php: 4 | - '5.6' 5 | - '7.0' 6 | - nightly 7 | 8 | before_script: 9 | - travis_retry composer self-update 10 | - travis_retry composer install --prefer-source --no-interaction --dev 11 | 12 | #notifications: 13 | # slack: chanel:token 14 | 15 | addons: 16 | code_climate: 17 | repo_token: c70199b1102996ce7de86c5ce4c89a4f308ca496ebb266deb21f41e7f4be75cb 18 | 19 | script: 20 | - "phpunit --process-isolation --coverage-clover build/logs/clover.xml" 21 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Fireguard Soluções em Tecnologia Ltda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fireguard Report 2 | 3 | [![Build Status](https://travis-ci.org/fireguard/report.png)](https://travis-ci.org/fireguard/report) 4 | [![Latest Stable Version](https://poser.pugx.org/fireguard/report/v/stable)](https://packagist.org/packages/fireguard/report) 5 | [![Latest Unstable Version](https://poser.pugx.org/fireguard/report/v/unstable)](https://packagist.org/packages/fireguard/report) 6 | [![Total Downloads](https://poser.pugx.org/fireguard/report/downloads)](https://packagist.org/packages/fireguard/report) 7 | [![License](https://poser.pugx.org/fireguard/report/license)](https://packagist.org/packages/fireguard/report) 8 | [![Code Climate](https://codeclimate.com/github/fireguard/report/badges/gpa.svg)](https://codeclimate.com/github/fireguard/report) 9 | 10 | [![SensioLabsInsight](https://insight.sensiolabs.com/projects/f378db1b-5a6a-4b13-b49d-ff28a9c29a62/big.png)](https://insight.sensiolabs.com/projects/f378db1b-5a6a-4b13-b49d-ff28a9c29a62) 11 | 12 | **Other languages for this documentation: [PORTUGUÊS](README_PT.md)** 13 | 14 | The **Fireguard Report** is a report management package in PHP that aims to help you export information in a variety of 15 | formats, such as HTML, PDF and IMAGE, using a unique, integrated and simple interface. 16 | 17 |
18 | # Summary 19 | 20 | - [Installation](#install) 21 | - [Installing and Updating PhantomJs](#install-phantom) 22 | - [How to use](#use) 23 | - [Generating our first report](#first-report) 24 | - [Header and Footer](#footer-header) 25 | - [Exporters](#exporters) 26 | - [Methods available in all Exports](#methods-exports) 27 | - [HtmlExporter](#html-exporter) 28 | - [PdfExporter](#pdf-exporter) 29 | - [ImageExporter](#image-exporter) 30 | 31 | - [Laravel](#laravel) 32 | - [Registering Service Provider](#laravel-register-provider) 33 | - [Publishing the configuration file](#laravel-publish-config) 34 | - [Examples of use with Laravel (Dependency Injection)](#laravel-use) 35 | - [Other usage examples](#examples) 36 | - [Generating an HTML report](#use-link-html) 37 | - [Generating an PDF report](#use-link-pdf) 38 | - [Generating an IMAGE report](#use-link-image) 39 | - [Sample ticket generated with this package](#use-link-boleto) 40 | 41 | 42 | #
Installation 43 | 44 | The FireGuard Report can be installed through the composer. 45 | 46 | In order for the package to be automatically added to your composer.json file, run the following command: 47 | 48 | ```bash 49 | composer require fireguard/report 50 | ``` 51 | 52 | Or if you prefer, add the following snippet manually: 53 | 54 | ``` 55 | { 56 | "require": { 57 | ... 58 | "fireguard/report": "^0.1" 59 | } 60 | } 61 | ``` 62 | 63 | ##
Installing and Updating PhantomJs 64 | 65 | To generate the PDF files and Images, this package is used by PhantomJs. For installation and update, we suggest two 66 | options: 67 | 68 | **1st Option:** Add the lines below in the composer.json file, so the installation and update process will occur every 69 | time you execute the "composer install" or "composer update" commands. 70 | 71 | ``` 72 | "scripts": { 73 | "post-install-cmd": [ 74 | "PhantomInstaller\\Installer::installPhantomJS" 75 | ], 76 | "post-update-cmd": [ 77 | "PhantomInstaller\\Installer::installPhantomJS" 78 | ] 79 | } 80 | ``` 81 | 82 | **2st Option:** If you do not want to always keep the latest PhantomJS version, one possibility is to add a new script 83 | in composer.json as shown below: 84 | 85 | ``` 86 | "scripts": { 87 | "update-phantomjs": [ 88 | "PhantomInstaller\\Installer::installPhantomJS" 89 | ] 90 | } 91 | ``` 92 | 93 | And run whenever you want to update the version of the executable the following command ``composer run-script update-phantomjs`` 94 | 95 | If you choose this option, you must run at least the first time for it to be installed. 96 | 97 | 98 | #
How to use 99 | 100 | ##
Generating our first report 101 | 102 | The use of this package is very simple, we will need two objects to generate a final file, the first one is Report, 103 | with it we define the effective content of the report, the second is the Exporter, which receives a Report and is 104 | responsible for handling the information and export to a final file. 105 | 106 | Here is a simple example to generate a file: 107 | 108 | ```php 109 | $report = new \Fireguard\Report\Report('

Report Title

'); 110 | $exporter = new \Fireguard\Report\Exporters\PdfExporter(); 111 | $file = $exporter->generate($report); 112 | ``` 113 | 114 | So at the end of the execution, in the variable **$file** we will have the actual path to the generated file. 115 | 116 | ##