redanlaxe/powerbi-embed-php
最新稳定版本:1.0.0
Composer 安装命令:
composer require redanlaxe/powerbi-embed-php
包简介
A PHP library to embed Power BI reports using the App Owns Data (service principal) method.
README 文档
README
A PHP library to embed Power BI reports using the "App Owns Data" (service principal) method.
Installation
Install the package via Composer:
composer require redanlaxe/powerbi-embed-php
Usage
-
Create a configuration array with your Azure AD and Power BI details.
// config.php return [ 'authenticationMode' => 'ServicePrincipal', 'workspaceId' => 'YOUR_WORKSPACE_ID', 'reportId' => 'YOUR_REPORT_ID', 'tenantId' => 'YOUR_TENANT_ID', 'clientId' => 'YOUR_CLIENT_ID', 'clientSecret' => 'YOUR_CLIENT_SECRET', // ... and other settings ];
-
Instantiate the
PbiEmbedServiceand get the embed parameters.<?php require 'vendor/autoload.php'; use App\Services\PbiEmbedService; $config = require 'config.php'; try { $pbiService = new PbiEmbedService($config); $embedConfig = $pbiService->getEmbedParamsForSingleReport($config['workspaceId'], $config['reportId']); // The $embedConfig object now contains the accessToken, embedUrl, etc. // Send this to your front-end as JSON. header('Content-Type: application/json'); echo json_encode($embedConfig); } catch (\Exception $e) { // Handle exceptions }
Running the Example
This repository contains an example implementation in the /examples directory. To run it:
- Clone the repository.
- Run
composer installin the root directory. - Update the configuration in
examples/config.phpwith your credentials. - Use PHP's built-in web server to run the example:
php -S localhost:8080 -t examples/public
- Open
http://localhost:8080in your browser.
License
This project is licensed under the MIT License.
统计信息
- 总下载量: 83
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-30