suminagashi / figures
为您的 symfony 应用提供简单的统计。
dev-master
2020-08-02 11:14 UTC
Requires
- php: >=7.1
- ext-ctype: *
- ext-iconv: *
- doctrine/annotations: ^1.0
- doctrine/orm: ^2.7
- symfony/asset: 5.1.*
- symfony/console: 5.1.*
- symfony/dotenv: 5.1.*
- symfony/finder: 5.1.*
- symfony/flex: ^1.3.1
- symfony/framework-bundle: 5.1.*
- symfony/property-access: 5.1.*
- symfony/property-info: 5.1.*
- symfony/twig-bundle: 5.1.*
- symfony/webpack-encore-bundle: ^1.7
- symfony/yaml: 5.1.*
- twig/extra-bundle: ^2.12|^3.0
- twig/twig: ^2.12|^3.0
This package is auto-updated.
Last update: 2024-09-29 05:55:48 UTC
README
# Figures
为您的 symfony 应用提供简单的统计。
安装包
即将推出 Flex 烹饪配方...
注册包
// config/bundles.php return [ ... Suminagashi\FiguresBundle\FiguresBundle::class => ['all' => true], ];
将 Figure 实体添加到您的数据库
php bin/console doctrine:schema:update --force
设置您的实体
首先您需要导入 Suminagashi\FiguresBundle\Annotation\Watch 注解。然后您必须写入统计的键、类型(累积或计数)以及生命周期(在哪个生命周期中注册统计)。
use Suminagashi\FiguresBundle\Annotation\Watch; class Product { //... /** * * @ORM\Column(type="integer") * * @Watch(key="product:price", type="cumul", lifecycle="update") * @Watch(key="product:sell", type="count", lifecycle="create") */ private $price; //***
这是如何工作的
统计计算有两种模式
count用于计算销售数量(例如)cumul用于计算销售金额(例如)
如何获取特定统计
首先您需要在您的代码中导入 Suminagashi\FiguresBundle\Tools\Figures。然后您可以将类自动注入并开始使用它。我们提供了一些方法来帮助您
$figures = new Figures(); $figures->all('key'); $figures->getToday('key'); $figures->getLastweek('key'); $figures->getLastmonth('key'); $figures->getLastyear('key'); $figures->get('key', 'start', 'end');
即将推出
- 统计百分比计算
- 统计类型
- 更好的异常处理
- 处理删除(级联)