{"id":37010340,"url":"https://github.com/fireguard/report","last_synced_at":"2026-01-14T00:59:35.749Z","repository":{"id":62504907,"uuid":"57446156","full_name":"fireguard/report","owner":"fireguard","description":"Report management package in PHP that aims to help you export information in a variety of formats","archived":true,"fork":false,"pushed_at":"2018-06-03T20:22:54.000Z","size":153,"stargazers_count":122,"open_issues_count":0,"forks_count":19,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-10-22T05:20:48.594Z","etag":null,"topics":["export","html","laravel","pdf","pdf-generation","phantomjs","php","report"],"latest_commit_sha":null,"homepage":"http://fireguard.com.br","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fireguard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-30T14:31:16.000Z","updated_at":"2025-06-14T06:32:34.000Z","dependencies_parsed_at":"2022-11-02T12:45:17.333Z","dependency_job_id":null,"html_url":"https://github.com/fireguard/report","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fireguard/report","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireguard%2Freport","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireguard%2Freport/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireguard%2Freport/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireguard%2Freport/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireguard","download_url":"https://codeload.github.com/fireguard/report/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireguard%2Freport/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["export","html","laravel","pdf","pdf-generation","phantomjs","php","report"],"created_at":"2026-01-14T00:59:35.079Z","updated_at":"2026-01-14T00:59:35.732Z","avatar_url":"https://github.com/fireguard.png","language":"PHP","readme":"# Fireguard Report\n\n[![Build Status](https://travis-ci.org/fireguard/report.png)](https://travis-ci.org/fireguard/report)\n[![Latest Stable Version](https://poser.pugx.org/fireguard/report/v/stable)](https://packagist.org/packages/fireguard/report)\n[![Latest Unstable Version](https://poser.pugx.org/fireguard/report/v/unstable)](https://packagist.org/packages/fireguard/report)\n[![Total Downloads](https://poser.pugx.org/fireguard/report/downloads)](https://packagist.org/packages/fireguard/report)\n[![License](https://poser.pugx.org/fireguard/report/license)](https://packagist.org/packages/fireguard/report)\n[![Code Climate](https://codeclimate.com/github/fireguard/report/badges/gpa.svg)](https://codeclimate.com/github/fireguard/report)\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/f378db1b-5a6a-4b13-b49d-ff28a9c29a62/big.png)](https://insight.sensiolabs.com/projects/f378db1b-5a6a-4b13-b49d-ff28a9c29a62)\n\n**Other languages for this documentation: [PORTUGUÊS](README_PT.md)**\n\nThe **Fireguard Report** is a report management package in PHP that aims to help you export information in a variety of \nformats, such as HTML, PDF and IMAGE, using a unique, integrated and simple interface.\n\n\u003cdiv id='summary'/\u003e\n# Summary \n\n- [Installation](#install)\n    - [Installing and Updating PhantomJs](#install-phantom)\n- [How to use](#use)\n    - [Generating our first report](#first-report)\n    - [Header and Footer](#footer-header)\n    - [Exporters](#exporters)\n        - [Methods available in all Exports](#methods-exports)\n        - [HtmlExporter](#html-exporter)\n        - [PdfExporter](#pdf-exporter)\n        - [ImageExporter](#image-exporter)\n        \n- [Laravel](#laravel)\n    - [Registering Service Provider](#laravel-register-provider)\n    - [Publishing the configuration file](#laravel-publish-config)\n    - [Examples of use with Laravel (Dependency Injection)](#laravel-use)\n- [Other usage examples](#examples)\n    - [Generating an HTML report](#use-link-html)\n    - [Generating an PDF report](#use-link-pdf)\n    - [Generating an IMAGE report](#use-link-image)\n    - [Sample ticket generated with this package](#use-link-boleto)\n\n\n# \u003cdiv id=\"install\" /\u003eInstallation\n\nThe FireGuard Report can be installed through the composer.\n\nIn order for the package to be automatically added to your composer.json file, run the following command:\n\n```bash\n  composer require fireguard/report\n```\n\nOr if you prefer, add the following snippet manually:\n\n```\n{\n  \"require\": {\n    ...\n    \"fireguard/report\": \"^0.1\"\n  }\n}\n```\n\n## \u003cdiv id=\"install-phantom\"/\u003eInstalling and Updating PhantomJs\n\nTo generate the PDF files and Images, this package is used by PhantomJs. For installation and update, we suggest two \noptions:\n\n**1st Option:** Add the lines below in the composer.json file, so the installation and update process will occur every \ntime you execute the \"composer install\" or \"composer update\" commands.\n\n```\n  \"scripts\": {\n    \"post-install-cmd\": [\n      \"PhantomInstaller\\\\Installer::installPhantomJS\"\n    ],\n    \"post-update-cmd\": [\n      \"PhantomInstaller\\\\Installer::installPhantomJS\"\n    ]\n  }\n```\n\n**2st Option:** If you do not want to always keep the latest PhantomJS version, one possibility is to add a new script \nin composer.json as shown below:\n\n```\n  \"scripts\": {\n    \"update-phantomjs\": [\n      \"PhantomInstaller\\\\Installer::installPhantomJS\"\n    ]\n  }\n```\n\nAnd run whenever you want to update the version of the executable the following command ``composer run-script update-phantomjs``\n\nIf you choose this option, you must run at least the first time for it to be installed.\n\n\n# \u003cdiv id=\"use\"/\u003eHow to use\n\n## \u003cdiv id=\"first-report\"/\u003eGenerating our first report\n\nThe use of this package is very simple, we will need two objects to generate a final file, the first one is Report, \nwith it we define the effective content of the report, the second is the Exporter, which receives a Report and is \nresponsible for handling the information and export to a final file.\n\nHere is a simple example to generate a file:\n\n```php\n    $report     = new \\Fireguard\\Report\\Report('\u003ch1\u003eReport Title\u003c/h1\u003e');\n    $exporter   = new \\Fireguard\\Report\\Exporters\\PdfExporter();\n    $file       = $exporter-\u003egenerate($report);    \n```\n\nSo at the end of the execution, in the variable **$file** we will have the actual path to the generated file.\n\n## \u003cdiv id=\"footer-header\" /\u003eHeader and Footer\n\nFor header and footer HTML, two variables are available in exporters that use paging, such as PdfExporter, **numPage**, \nand **totalPages**, which contains the current page and the total pages of the page respectively. \nTo access them, you must enclose them by \"@{{  }}\", so the contents of the content will be automatically updated.\nBelow is a simple example that will use the header and footer;\n\n```php \n  $html   = file_get_contents('report.html');\n  \n  $header = '\u003cdiv style=\"text-align: center;font-size: 20px; border-bottom: 1px #eeeeee solid; padding: 1px; \"\u003e';\n  $header.= '    \u003cstrong\u003eTHE MANAGEMENT REPORT TITLE\u003c/strong\u003e';\n  $header.= '\u003c/div\u003e';\n\n  $footer = '\u003cdiv style=\"text-align: right;font-size: 10px; border-top: 1px #eeeeee solid; padding: 2px;\"\u003e';\n  $footer.= '    Page \u003cspan\u003e@{{ numPage }} of @{{ totalPages }}\u003c/span\u003e';\n  $footer.= '\u003c/div\u003e';\n  \n  $report = new \\Fireguard\\Report\\Report($html, $header, $footer);\n  $exporter = new \\Fireguard\\Report\\Exporters\\PdfExporter('.', 'report1-to-pdf');\n  $file   = $exporter-\u003egenerate($report);\n  \n```\nWith this example above we will find in the variable **$file** the path to the generated PDF file;\n\n## \u003cdiv id=\"exporters\" /\u003eExporters\n\nAs we saw in the previous examples, the export of the report requires an Exporter class. An Exporter is a specialized \nclass that implements an ExporterInterface interface and is responsible for catching a Report object and transforming it \ninto a finalized file. \n\nAt this point we have included in the package three Exporters, one for HTML, one for PDF and one for Images, it is \npossible that in future new Exporters will be available, we also encourage you to develop new Exporters and, if \npossible, contribute to the project.\n\n### \u003cdiv id=\"methods-exports\" /\u003eMethods available in all Exports\n\n``getPath()``: Returns the location where the generated file will be saved;\n\n``setPath($path, $mode = 0777)``: Sets the location where the file should be saved;\n\n``getFileName()``: Returns the name of the file to save;\n\n``setFileName($fileName)``: Sets the name of the file to be saved;\n\n``getFullPath()``: Returns the complete path with the name of the file to be generated;\n\n``compress($buffer)``: Returns a compressed string with no comments or line breaks;\n\n``configure(array $config)``: Sets the settings to apply to the current report;\n\n``generate(ReportInterface $report)``: Renders the report and returns a path to the generated file;\n\n``response(ReportInterface $report, $forceDownload)``: Renders the report and returns an instance of the Symfony\\Component\\HttpFoundation\\Response;\n\nExample of use with a fluent interface:\n\n```php\n$report = new \\Fireguard\\Report\\Report('\u003ch1\u003eReport Title\u003c/h1\u003e');\n$exporter = new \\Fireguard\\Report\\Exporters\\PdfExporter();\n// Example returning an HTTP response\n$exporterGenerates report\n    -\u003esetPath('.') // Sets the save to the local folder\n    -\u003esetFileName('report.pdf') // Define as 'report.pdf' the name of the file to be generated\n    -\u003econfigure(['footer' =\u003e ['height' =\u003e '30px']) // Set the footer size to 30px\n    -\u003eresponse($report) // Create an HTTP response\n    -\u003esend(); // Returns the response to the user\n    \n// Example generating a local file\n$file = $exporter\n    -\u003esetPath('.') // Sets the save to the local folder\n    -\u003esetFileName('report.pdf') // Define as 'report.pdf' the name of the file to be generated\n    -\u003econfigure(['footer' =\u003e ['height' =\u003e '30px']) // Set the footer size to 30px\n    -\u003egenerate($report); // Generates report\n          \n```\n\n### \u003cdiv id=\"html-exporter\" /\u003e HtmlExport\n\nFor exporting files in **HTML** format, in addition to the standard methods, some others are available, below all are \nlisted with a brief description of their function:\n\n``saveFile($content)``: Saves the HTML file and returns the full path to the generated file;\n\n### \u003cdiv id=\"pdf-exporter\" /\u003ePdfExport\n\nFor exporting files in **PDF** format, in addition to the standard methods, some others are available, below all are \nlisted with a brief description of their function:\n\n``getFormat()``: Returns the defined paper size;\n\n``setFormat($format)``: Sets a paper size to be exported. (Valid Formats: 'A4', 'A3', 'Letter')\n\n``getOrientation()``: Returns the orientation of the defined paper;\n\n``setOrientation($orientation)``: Sets the orientation of the paper to be exported. (Valid Orientations: 'landscape', 'portrait')\n\n``getMargin()``: Returns the defined paper margin;\n\n``setMargin($margin)``: Sets the paper margin to be exported;\n\n``getBinaryPath()``: Returns the path to the PhantomJS binary in the application;\n\n``setBinaryPath($binaryPath)``: Sets the path to the PhantomJS binary file in the application;\n\n``getCommandOptions()``: Returns the parameters to be executed with the PhantomJS for export;\n\n``setCommandOptions(array $options)``: Sets the parameters to be executed with the PhantomJS for export;\n\n``addCommandOption($option, $value)``: Adds a new parameter to run with PhantomJS for export;\n\n``getHeaderHeight()``: Returns the size of the header defined;\n\n``getFooterHeight()``: Returns the size of the footer defined;\n\n### \u003cdiv id=\"image-exporter\" /\u003eImageExport\n\nFor exporting files in **IMAGE** format, in addition to the standard methods, some others are available, below all are \nlisted with a brief description of their function:\n\n``getFormat()``: Returns the defined paper size;\n\n``setFormat($format)``: Sets a paper size to be exported. (Valid Formats: 'A4', 'A3', 'Letter')\n\n``getOrientation()``: Returns the orientation of the defined paper;\n\n``setOrientation($orientation)``: Sets the orientation of the paper to be exported. (Valid Orientations: 'landscape', 'portrait')\n\n``getMargin()``: Returns the defined paper margin;\n\n``setMargin($margin)``: Sets the paper margin to be exported;\n\n``getBinaryPath()``: Returns the path to the PhantomJS binary in the application;\n\n``setBinaryPath($binaryPath)``: Sets the path to the PhantomJS binary file in the application;\n\n``getCommandOptions()``: Returns the parameters to be executed with the PhantomJS for export;\n\n``setCommandOptions(array $options)``: Sets the parameters to be executed with the PhantomJS for export;\n\n``addCommandOption($option, $value)``: Adds a new parameter to run with PhantomJS for export;\n\n``getHeaderHeight()``: Returns the size of the header defined;\n\n``getFooterHeight()``: Returns the size of the footer defined;\n\n\n# \u003cdiv id=\"laravel\" /\u003e Laravel\n\nThe steps described below are optional and can only make it easier for those who want to use this package with Laravel 5.\n\n## \u003cdiv id=\"laravel-register-provider\" /\u003e Registering Service Provider\n\nIn the ``config\\app.php`` configuration file, register above the providers of your application as follows:\n\n```\n'providers' =\u003e [\n    Fireguard\\Report\\Laravel\\ReportServiceProvider::class,\n    ...\n]\n```\n\n## \u003cdiv id=\"laravel-publish-config\" /\u003e Publishing the configuration file\n\nTo publish the configuration file you must use the following command:\n```\nphp artisan vendor:publish --provider=\"Fireguard\\Report\\Laravel\\ReportServiceProvider\"\n```\n\n## \u003cdiv id=\"laravel-use\" /\u003e Examples of use with Laravel (Dependency Injection)\n\nWith the registration of the service provider, you can now use the dependency injection of Laravel to solve the \nexporters, already bringing them ready and configured with the application configuration file.\n\nFor dependency injection four classes are available, one interface and three concrete, the default interface is solved \nfor the concrete PdfExporter class, which can be changed in the ``default-exporter`` parameter of the configuration \nfile ``report.php`` generated in the integration. See below some examples of use.\n\n### \u003cdiv id=\"laravel-injection-interface\" /\u003e Exporter Interface\n\n```php\n    public function index (\\Fireguard\\Report\\Exporters\\ExporterInterface $exporter)\n    {\n        $html = view()-\u003emake('welcome')-\u003erender();\n        \n        // Option 1\n        return $exporter\n            -\u003eresponse(new Report($html))\n            -\u003esend();\n        \n        // Option 2\n        $file = $exporter-\u003egenerate(new Report($html));\n        $headers = [\n            'Content-type' =\u003e mime_content_type($file),\n            'Content-Transfer-Encoding' =\u003e 'binary',\n            'Content-Length' =\u003e filesize($file),\n            'Accept-Ranges' =\u003e 'bytes'\n        ];\n        // If you want to directly display the file\n        return response()-\u003emake(file_get_contents($file), 200, $headers);\n        // If you want to force download\n        // return response()-\u003edownload($file, 'report.pdf', $headers);\n    }\n```\n\n### \u003cdiv id=\"laravel-injection-html\" /\u003e HtmlExporter Class\n\n```php\n    public function index (\\Fireguard\\Report\\Exporters\\HtmlExporter $exporter)\n    {\n        $html = view()-\u003emake('welcome')-\u003erender();\n        // Option 1\n        return $exporter\n            -\u003eresponse(new Report($html))\n            -\u003esend();\n            \n                \n        // Option 2\n        $file = $exporter-\u003egenerate(new Report($html));\n        // If you want to directly display the file\n        // return response()-\u003emake(file_get_contents($file), 200);\n        // If you want to force download\n        return response()-\u003edownload($file, 'report.html', []);\n    }\n```\n\n### \u003cdiv id=\"laravel-injection-pdf\" /\u003e PdfExporter Class\n\n```php\n    public function index (\\Fireguard\\Report\\Exporters\\PdfExporter $exporter)\n    {\n        $html = view()-\u003emake('welcome')-\u003erender();\n        // Option 1\n        return $exporter\n            -\u003eresponse(new Report($html))\n            -\u003esend();\n                    \n                        \n        // Option 2\n        $file = $exporter-\u003egenerate(new Report($html));\n        $headers = [\n            'Content-type' =\u003e 'application/pdf',\n            'Content-Transfer-Encoding' =\u003e 'binary',\n            'Content-Length' =\u003e filesize($file),\n            'Accept-Ranges' =\u003e 'bytes'\n        ];\n        // If you want to directly display the file\n        return response()-\u003emake(file_get_contents($file), 200, $headers);\n        // If you want to force download\n        // return response()-\u003edownload($file, 'report.pdf', $headers);\n    }\n```\n\n### \u003cdiv id=\"laravel-injection-image\" /\u003e ImageExporter Class\n\n```php\n    public function index (\\Fireguard\\Report\\Exporters\\ImageExporter $exporter)\n    {\n        $html = view()-\u003emake('welcome')-\u003erender();\n        \n        // Option 1\n        return $exporter\n            -\u003eresponse(new Report($html))\n            -\u003esend();\n                            \n                                \n        // Option 2\n        $file = $exporter-\u003egenerate(new Report($html));\n        $headers = [\n            'Content-type' =\u003e 'image/jpg',\n            'Content-Length' =\u003e filesize($file),\n        ];\n        // If you want to directly display the file\n        return response()-\u003emake(file_get_contents($file), 200, $headers);\n        // If you want to force download\n        // return response()-\u003edownload($file, 'report.jpg', $headers);\n    }\n```\n\n# \u003cdiv id=\"examples\" /\u003e Other usage examples\n\u003cbr /\u003e\n    \u003ca href=\"examples/report1-html.php\" target=\"_blank\" id=\"use-link-html\"\u003e Generating an HTML report\u003c/a\u003e \u003cbr /\u003e\n    \u003ca href=\"examples/report1-pdf.php\" target=\"_blank\" id=\"use-link-pdf\"\u003e Generating an PDF report\u003c/a\u003e \u003cbr /\u003e\n    \u003ca href=\"examples/report1-image.php\" target=\"_blank\" id=\"use-link-image\"\u003e Generating an IMAGE report\u003c/a\u003e \u003cbr /\u003e\n    \u003ca href=\"examples/report-boleto.pdf\" target=\"_blank\" id=\"use-link-boleto\"\u003e Sample ticket generated with this package\u003c/a\u003e \n\u003cbr /\u003e\n\u003cbr /\u003e\u003cbr /\u003e\u003cbr /\u003e\nCreated by Fireguard Sistemas \u003ca href=\"http://fireguard.com.br\"\u003ehttp://fireguard.com.br\u003c/a\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireguard%2Freport","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireguard%2Freport","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireguard%2Freport/lists"}