定制 riipandi/php-metabase 二次开发

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

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

riipandi/php-metabase

最新稳定版本:v1.2

Composer 安装命令:

composer require riipandi/php-metabase

包简介

Embedding Metabase on your PHP application

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Library to embed Metabase frames. Forked from ipeevski/metabase-php

Installation

  • Install via composer: composer require riipandi/php-metabase
  • Go to Metabase and enable embedding - https://{metabase_url}/admin/settings/embedding_in_other_applications
  • Note down the Metabase base url and the Embedding secret key

Basic usage

First, you need to find the dashboard or question you want to embed. Note down the id - it would be at the end of the URL (for example https://{metabase_url}/dashboard/1?date=past26weeks

Note the integer after /dashboard/ - that's the ID of the dashboard. Also note the GET parameters at the end of the url - those are parameters you might want to pass to the dashboard too.

<?php

include 'vendor/autoload.php';

$metabaseUrl = '[metabase_url]';      // The url of the metabase installation
$metabaseKey = '[metabase_key]';      // The metabase secret embed key
$dashboardId = 1;                     // The id of the dashboard (from the url)
$params = ['date' => 'past26weeks'];  // Any parameters to pass to the dashboard (optional)

$metabase = new \Metabase\Embed($metabaseUrl, $metabaseKey);

// Generate the HTML to create an iframe with the embedded dashboard
echo $metabase->dashboardIframe($dashboardId, $params);

Using Laravel

Create config file at confog/metabase.php

<?php

return [
    'url' => env('METABASE_URL', 'http://localhost:3000'),
    'key' => env('METABASE_KEY'),
]
<?php

$metabaseUrl = config('metabase.url');    // The url of the metabase installation
$metabaseKey = config('metabase.key');    // The metabase secret embed key
$dashboardId = 1;                         // The id of the dashboard (from the url)
$params = ['date' => 'past26weeks'];      // Any parameters to pass to the dashboard (optional)

$metabase = new \Metabase\Embed($metabaseUrl, $metabaseKey);

// Generate the HTML to create an iframe with the embedded dashboard
echo $metabase->dashboardIframe($dashboardId, $params);

License

MIT: https://aris.mit-license.org/

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-01-21