PHP code example of bumbal / rancher-php-client

1. Go to this page and download the library: Download bumbal/rancher-php-client 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/ */

    

bumbal / rancher-php-client example snippets





    $rancherClient = new Rancher\RancherClient("https://your.racher.url/", "rancher_token", "rancher_secret");
    
    $namespaceResource = new \Rancher\Resource\NamespaceResource($rancherClient, "c-abcdef");
    $namespaceModel = new \Rancher\Model\NamespaceModel();
    $namespaceModel->setName('from-php-api');
    $namespaceModel->setDescription('Namespace generated with Rancher PHP Client');
    $namespaceModel->setProjectId('c-abcdef:p-qwerty');

    print_r($namespaceResource->create($namespaceModel));
}
catch (\Rancher\RancherException $e)
{
    echo $e->getMessage();
}