PHP code example of phil / reporting-bundle

1. Go to this page and download the library: Download phil/reporting-bundle 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/ */

    

phil / reporting-bundle example snippets


use Phil\ReportingBundle\Application\Contract\MetricSource;
use Phil\ReportingBundle\Domain\ValueObject\Metric;
use Phil\ReportingBundle\Domain\ValueObject\Period;

final readonly class OrdersTaken implements MetricSource
{
    public function __construct(private OrderRepository $orders) {}

    public static function key(): string { return 'orders'; }

    public function title(): string { return 'Orders'; }

    public function metric(Period $period): Metric
    {
        return new Metric($this->orders->countBetween($period->start, $period->end));
    }
}
yaml
# config/packages/phil_reporting.yaml
phil_reporting:
    timezone: America/Toronto
    dashboards:
        sales:
            title: Sales
            periods: [last_30_days, this_month, last_month]
            widgets:
                - { metric: orders, compare: true }