sbc / auto-reporting-bundle
发送关于应用程序活动的每日PDF报告
dev-master / 1.x-dev
2018-05-14 14:16 UTC
Requires
- php: >=5.5.9
- dompdf/dompdf: ^0.8.2
- symfony/framework-bundle: ^2.8 || ^3.0
This package is not auto-updated.
Last update: 2024-09-18 04:38:54 UTC
README
发送关于应用程序活动的每日PDF报告。
安装
composer require sbc/auto-reporting-bundle- 在 AppKernel.php 中启用该包
new SBC\AutomaticReportingBundle\AutomaticReportingBundle(),
用法
步骤1
设置配置
# AutomaticReportingBundle configuration
automatic_reporting:
app_name: 'Your applciation name' # will be displayed in the email
recipients: ['mail1@site.com', 'mail2@site.com'] # multiple recipients
步骤2
在您想要跟踪的实体中调用 @Report 注解
/** * Post * * @ORM\Table(name="post") * @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository") * * @Report( * dateColumn="creationDate", * reportingName="Poste" * ) */ class Post { ... }
步骤2(区分解决方案)
您还可以使用区分列注解(DifferentiationColumn Annotation)对同一实体的结果进行区分
/** * Post * * @ORM\Table(name="post") * @ORM\Entity(repositoryClass="AppBundle\Repository\PostRepository") * * @Report( * dateColumn="creationDate", * differentiationColumn="type", * differentiations={ * @DifferentiationColumn(value="A", reportingName="Post of type A"), * @DifferentiationColumn(value="B", reportingName="Post of type B") * } * ) */ class Post { ... /** * Type of the Post entity * @var string * * @ORM\Column(name="type", type="string", length=255) */ private $type; }
步骤3
- 调用
php bin/console reporting:generate来构建并发送报告 - 或者创建一个定时任务(cron job),每天触发此命令
实际上会发生什么?
调用命令后,包将解析并获取所有带有 @Report 注解的实体,并使用 dateColumn 属性统计当前天创建的所有行数,然后包将生成并发送包含每个实体使用 reportingName 属性的摘要的PDF附件给收件人。