PHP code example of mangati / portainer-api

1. Go to this page and download the library: Download mangati/portainer-api library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mangati / portainer-api example snippets


$portainer = new \Mangati\Portainer\Client('http://127.0.0.1:9000');
$portainer->auth('admin', '123456789');

$endpointsApi = $portainer->endpoints();
$endpoints    = $endpointsApi->getAll();

print_r($endpoints);

$stacksApi = $portainer->stacks($endpoints[0]['Id']);
$stacks    = $stacksApi->getAll();

print_r($stacks);

if (count($stacks)) {
    $stacksApi->delete($stacks[0]['Id']);
}