PHPackages                             khoelck/phppowerbi - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. khoelck/phppowerbi

ActiveLibrary[API Development](/categories/api)

khoelck/phppowerbi
==================

A library for working with PowerBI embedded reports directly from PHP

v1.4(2y ago)129MITPHP

Since Jul 27Pushed 2y ago1 watchersCompare

[ Source](https://github.com/khoelck0315/PhpPowerBI)[ Packagist](https://packagist.org/packages/khoelck/phppowerbi)[ RSS](/packages/khoelck-phppowerbi/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (1)Versions (6)Used By (0)

PhpPowerBI
==========

[](#phppowerbi)

PhpPowerBI is a simple library for working with PowerBI embedded reports directly from PHP. It leverages the [microsoft/PowerBI-Javascript](https://github.com/microsoft/PowerBI-JavaScript) powerbi.js file for the actual rendering of the reports. **It has not been included in this repo** and must be downloaded separately [here](https://github.com/microsoft/PowerBI-JavaScript/tree/master/dist).

Dependencies
============

[](#dependencies)

PhpPowerBI relies on [PhpAzureAuth](https://github.com/khoelck0315/PhpAzureAuth/tree/main) to generate auth tokens for Azure. If you install via Composer, it will automatically install this as a dependency. The above mentioned *powerbi.js* or *powerbi.min.js* file is also required.

Installation
============

[](#installation)

The recommended way to install is via composer

### Composer install

[](#composer-install)

```
composer require khoelck/phppowerbi

```

[PhpPowerBI on Packagist](https://packagist.org/packages/khoelck/phppowerbi)

### Manual install

[](#manual-install)

Copy the contents of the src folder to your include\_path, and include the libraries in your authentication script as below:

```
require "includes/classes/PowerBI/PowerBIReport.php";
use Khoelck\PhpPowerBI\PowerBIReport;

```

Initial Configuration
=====================

[](#initial-configuration)

Each report you embed will need it's own JSON configuration file, based off of [these parameters](https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/configure-report-settings) provided by Microsoft for calling the PowerBI API. This should be placed in your include\_path along with the PowerBIConfig.php file. See EmbedExample.json for an example.

Be sure to include the *powerbi.js* or *powerbi.min.js* file in your page, before you call any methods from PHPPowerBI of course:

```

```

Use Case
========

[](#use-case)

You want to embed a PowerBI report in your PHP application - but you don't want to use the secure embed iframe option because it requires users to login. It would be better to obtain an Azure Token at time of login, then call the PowerBI API to display the report.

Leverage the AzureAuth API in your authentication script, which stores the token in your $\_SESSION variable. Then, when calling the PowerBIRepot constructor, pass in the $\_SESSION\['Token'\] variable to access and embed your report on the page.

Embedding Reports
=================

[](#embedding-reports)

The constructor for PowerBIReport takes 4 parameters:

- Your Report ID GUID
- Your Workspace ID GUID
- The name of the JSON file containing settings that will be used to render the report
- The Azure token to be passed when accessing the report

```
