定制 redanlaxe/powerbi-embed-php 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

  1. 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
    ];
  2. Instantiate the PbiEmbedService and 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:

  1. Clone the repository.
  2. Run composer install in the root directory.
  3. Update the configuration in examples/config.php with your credentials.
  4. Use PHP's built-in web server to run the example:
    php -S localhost:8080 -t examples/public
  5. Open http://localhost:8080 in your browser.

License

This project is licensed under the MIT License.

统计信息

  • 总下载量: 83
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-30