inserve / metabase-api-php
A PHP wrapper for the Metabase API
0.1.7
2024-09-30 14:45 UTC
Requires
- php: ^8.2
- guzzlehttp/guzzle: ^7.7
- lcobucci/jwt: ^5.3
- phpdocumentor/reflection-docblock: ^5.3
- psr/log: ^3.0
- symfony/property-access: ^6.3|^7
- symfony/serializer: ^6.3|^7
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.2
- squizlabs/php_codesniffer: ^3.7
- vimeo/psalm: ^5.22
README
Inserve API
A PHP Wrapper for Metabase
Requirements
Installation
composer require inserve/metabase-api-php
Example usage
<?php
use GuzzleHttp\Client;
use Inserve\MetabaseAPI\MetabaseAPI;
use Inserve\MetabaseAPI\Model\Database\Database;
use Inserve\MetabaseAPI\Model\Database\Details;
require 'vendor/autoload.php';
/** Setup a client and authenticate */
$client = new Client(['base_uri' => 'http://localhost:3000/']);
$api = new MetabaseAPI($client);
$api->authenticate('username', 'password');
/** Create a new database in Metabase */
$details = new Details();
$details
->setHost('127.0.0.1')
->setDbname('inserve-database')
->setUser('example')
->setPort(3306)
->setPassword('example')
;
$database = new Database();
$database
->setName('Inserve Metabase')
->setEngine('mysql')
->setDetails($details)
;
$result = $api->database->create($database);