chrisbeaver/powerbi-php
Composer 安装命令:
composer require chrisbeaver/powerbi-php
包简介
PowerBI API Wrapper for PHP
README 文档
README
Usage
- To prepare a dataset on PowerBI, use the Resources provided to design the dataset and tables.
$dataSet = Beaver\PowerBI\Resources\DataSet\DataSet::create('Testing Database from API');
With the dataset created, we can now create tables to add to it.
use Beaver\PowerBI\Resources\DataSet\Table;
use Beaver\PowerBI\Resources\DataSet\Type;
$table1 = Table::create('person')
->addColumn('name', Type::STRING)
->addColumn('birthday', Type::DATETIME)
->addColumn('age', Type::INTEGER);
$table2 = Table::create('account')
->addColumn('amount', Type::DOUBLE)
->addColumn('last_deposit', Type::DATETIME);
Now we have a dataset and tables, we just need to assign the tables to the dataset.
$dataSet->addTable($table1)->addTable($table2);
With everything built, time to put it on the server.
- Submit the dataset to the server.
First build the HTTP client.
$client = new Beaver\PowerBI\Http\Client($client_id, $client_secret, $username, $password);
Now use the client to post the dataset to the server and get our response.
$response = $client->dataSet()->create($dataSet);
We get back a response array from the server, and in this array we can get the PowerBI UUID assigned to the dataset so we can then add rows of data to it.
$dataSetID = $response['id'];
Next we can add some data to the schema we designed using the tables and columns. Here we'll just create some rows of data for the account table.
$rows1 = [
['amount' => 300.50, 'last_deposit' => '09/10/2012'],
['amount' => 212.12, 'last_deposit' => '09/07/2019'],
];
$rows2 = [
['amount' => 99.50, 'last_deposit' => '01/23/2017'],
['amount' => 10.00, 'last_deposit' => '01/29/2015'],
];
This demo is just preparing two different requests for entering data to the account table we created before. Always use an array of rows. With our client already established, we use this to make additional requests to the server for adding our data.
$client->dataSet()->addRows($dataSetID, 'account', $rows1);
$client->dataSet()->addRows($dataSetID, 'account', $rows2);
We now have a dataset with data populated in it on the PowerBI server ready for designing reports.
chrisbeaver/powerbi-php 适用场景与选型建议
chrisbeaver/powerbi-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 12 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 chrisbeaver/powerbi-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 chrisbeaver/powerbi-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 12
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-21