1. Go to this page and download the library: Download fireguard/report library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fireguard / report example snippets
$report = new \Fireguard\Report\Report('<h1>Report Title</h1>');
$exporter = new \Fireguard\Report\Exporters\PdfExporter();
$file = $exporter->generate($report);
$report = new \Fireguard\Report\Report('<h1>Report Title</h1>');
$exporter = new \Fireguard\Report\Exporters\PdfExporter();
// Example returning an HTTP response
$exporterGenerates report
->setPath('.') // Sets the save to the local folder
->setFileName('report.pdf') // Define as 'report.pdf' the name of the file to be generated
->configure(['footer' => ['height' => '30px']) // Set the footer size to 30px
->response($report) // Create an HTTP response
->send(); // Returns the response to the user
// Example generating a local file
$file = $exporter
->setPath('.') // Sets the save to the local folder
->setFileName('report.pdf') // Define as 'report.pdf' the name of the file to be generated
->configure(['footer' => ['height' => '30px']) // Set the footer size to 30px
->generate($report); // Generates report
public function index (\Fireguard\Report\Exporters\ExporterInterface $exporter)
{
$html = view()->make('welcome')->render();
// Option 1
return $exporter
->response(new Report($html))
->send();
// Option 2
$file = $exporter->generate(new Report($html));
$headers = [
'Content-type' => mime_content_type($file),
'Content-Transfer-Encoding' => 'binary',
'Content-Length' => filesize($file),
'Accept-Ranges' => 'bytes'
];
// If you want to directly display the file
return response()->make(file_get_contents($file), 200, $headers);
// If you want to force download
// return response()->download($file, 'report.pdf', $headers);
}
public function index (\Fireguard\Report\Exporters\HtmlExporter $exporter)
{
$html = view()->make('welcome')->render();
// Option 1
return $exporter
->response(new Report($html))
->send();
// Option 2
$file = $exporter->generate(new Report($html));
// If you want to directly display the file
// return response()->make(file_get_contents($file), 200);
// If you want to force download
return response()->download($file, 'report.html', []);
}
public function index (\Fireguard\Report\Exporters\PdfExporter $exporter)
{
$html = view()->make('welcome')->render();
// Option 1
return $exporter
->response(new Report($html))
->send();
// Option 2
$file = $exporter->generate(new Report($html));
$headers = [
'Content-type' => 'application/pdf',
'Content-Transfer-Encoding' => 'binary',
'Content-Length' => filesize($file),
'Accept-Ranges' => 'bytes'
];
// If you want to directly display the file
return response()->make(file_get_contents($file), 200, $headers);
// If you want to force download
// return response()->download($file, 'report.pdf', $headers);
}
public function index (\Fireguard\Report\Exporters\ImageExporter $exporter)
{
$html = view()->make('welcome')->render();
// Option 1
return $exporter
->response(new Report($html))
->send();
// Option 2
$file = $exporter->generate(new Report($html));
$headers = [
'Content-type' => 'image/jpg',
'Content-Length' => filesize($file),
];
// If you want to directly display the file
return response()->make(file_get_contents($file), 200, $headers);
// If you want to force download
// return response()->download($file, 'report.jpg', $headers);
}