weble / laravel-databox
Laravel的数据框API集成
dev-main
2023-07-03 15:23 UTC
Requires
- php: ^8.0
- illuminate/contracts: ^9.0
- spatie/laravel-package-tools: ^1.13.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-09-09 18:18:35 UTC
README
Laravel的数据框集成,支持发送指标和检索可用指标列表。
数据在Laravel应用程序发送响应后通过单个推送请求发送,以避免影响用户。也可以通过配置文件中的简单选项将数据推送操作移动到队列中。
示例用法
use \LaravelDataBox\Facades\DataBox; // gets the default source $source = DataBox::source(); // Push a new metric $source->push(new Metric( key: 'sales', value: 888.22, ));
安装
您可以通过Composer安装此包
composer require weble/laravel-databox
您可以使用以下命令发布配置文件
php artisan vendor:publish --tag="laravel-databox-config"
这是已发布配置文件的内容,每个选项都有注释
<?php return [ // name of the default source, used when not passing a specific source name 'default_source' => 'default', // should the data be pushed with a queued job? // default setting, can be overridden per source 'queue' => false, // List of sources, you can create as many as you want, each with its // own token and queue setting 'sources' => [ 'default' => [ // The token generated in the databox UI 'token' => env('DATABOX_TOKEN', ''), // Each source can override the queue setting. // null means use the default setting above 'queue' => null, ], // More sources.... ], ];
使用方法
您可以通过facade LaravelDataBox\Facades\DataBox
与DataBox API进行交互
推送单个指标
use \LaravelDataBox\Facades\DataBox; // gets the default source $source = DataBox::source(); // Push a new metric $source->push(new Metric( key: 'sales', // Adds automatically the $ sign if not present value: 888.22, // any float / int value ));
推送多个指标
use \LaravelDataBox\Facades\DataBox; $source = DataBox::source(); $source->push([ new Metric( key: 'sales', value: 888.22, ), new Metric( key: 'sales', value: 72, ), ]);
指标选项完整列表
use \LaravelDataBox\Facades\DataBox; $source = DataBox::source(); $source->push(new Metric( key: 'sales', value: 888.22, date: now()->subDay(), // date of the metric event attributes: [ // Custom attributes for dimensions 'channel' => 'sales' ], 'unit' => 'EUR', // Unit of the value ));
使用不同的来源
use \LaravelDataBox\Facades\DataBox; $source = DataBox::source('other_source'); $source->push(new Metric( key: 'sales', value: 888.22 ));
测试
composer test
变更日志
请参阅变更日志以获取有关最近更改的更多信息。
贡献
请参阅贡献指南以获取详细信息。
安全漏洞
请审查我们的安全策略以了解如何报告安全漏洞。
致谢
许可
MIT许可(MIT)。请参阅许可文件以获取更多信息。