PHP code example of 3neti / report-registry
1. Go to this page and download the library: Download 3neti/report-registry 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/ */
3neti / report-registry example snippets
ReportResolverInterface
$result = $executor->execute('sales', format: 'raw');
[
'report' => [...],
'data' => [...],
'meta' => [...]
]
$json = $executor->execute('sales', format: 'json');
$html = $executor->execute('sales', format: 'html');
$executor = app(ReportExecutor::class);
// Raw payload
$data = $executor->execute('sales', format: 'raw');
// JSON output
$json = $executor->execute('sales', format: 'json');
// HTML output
$html = $executor->execute('sales', format: 'html');
class SalesReportResolver implements ReportResolverInterface
{
public function resolve(
array $filters = [],
?string $sort = null,
string $sortDirection = 'desc',
int $perPage = 10,
int $page = 1,
): array {
return [
'data' => [
[
'reference' => 'INV-001',
'amount' => 1250.50,
'status' => 'approved',
]
],
'meta' => [
'total' => 1,
'page' => 1,
'per_page' => $perPage,
],
];
}
}
ReportFormatterInterface
public function format(ReportDriverData $driver, array $data, array $meta): string;
bash
php artisan report:run sales --format=json
php artisan report:run sales --format=html
php artisan report:run sales --format=raw