1. Go to this page and download the library: Download benmag/laravel-rancher 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/ */
benmag / laravel-rancher example snippets
'providers' => [
// ... other providers
Benmag\Rancher\RancherServiceProvider::class,
]
namespace App\Http\Controllers;
use Rancher;
use App\Http\Controllers\Controller;
class HostController extends Controller
{
public function index()
{
return response()->json(Rancher::host()->all());
}
}
Rancher::host()->get("1h1");
Rancher::host()->activate("1h1");
Rancher::host()->evacuate("1h1");
Rancher::host()->remove("1h1");
Rancher::container()->all();
Rancher::container()->get("1i140");
use Rancher;
use Benmag\Rancher\Factories\Entity\Container;
$newContainer = new Container([
'name' => 'HelloWorld',
'description' => 'New container created via Laravel Rancher',
'imageUuid' => "docker:ubuntu:14.04.3",
]);
Rancher::container()->create($newContainer);
use Rancher;
use Benmag\Rancher\Factories\Entity\Stack;
$updatedStack = new Stack([
'name' => "my-updated-stack",
'description' => 'An updated stack',
]);
Rancher::stack()->update("1st312", $updatedStack);
Rancher::stack()->activateServices("1st312");
Rancher::stack()->deactivateServices("1st312");
Rancher::stack()->delete("1st312");
use Rancher;
use Benmag\Rancher\Factories\Entity\Project;
$project = new Project([
'name' => 'Hello World',
]);
Rancher::project()->create($project);
Rancher::project()->activate("1a8");
Rancher::project()->deactivate("1a8");
Rancher::project()->delete("1a8");
use Rancher;
use Benmag\Rancher\Factories\Entity\Service;
$newService = new Service([
'name' => 'newService',
'stackId' => '1st312',
'launchConfig' => [
'stdinOpen' => true,
'imageUuid' => 'docker:ubuntu:14.04.3'
],
]);
Rancher::service()->project("1a8")->create($newService);
use Rancher;
use Benmag\Rancher\Factories\Entity\Service;
$updatedService = new Service([
"description" => "I was updated",
"name" => "db",
"scale" => 1
]);
Rancher::service()->project("1a8")->update("1s23", $updatedService);
use Rancher;
$remove = ['serviceId' => '1s23'];
Rancher::loadBalancerService()->removeServiceLink("1s24", $remove);
use Rancher;
use Benmag\Rancher\Factories\Entity\Registry;
$registry = new Registry([
'serverAddress' => "registry.example.com",
]);
$registryResponse = Rancher::registry()->project("1a8")->create($registry));
use Rancher;
use Benmag\Rancher\Factories\Entity\RegistryCredential;
$cred = new RancherRegistryCredential([
'registryId' => "1sp120",
'email' => "[email protected]",
'publicValue' => "username",
'secretValue' => "password"
]);
Rancher::registryCredential()->create($cred);
$params = [
'name' => 'Hello World', // name = "Hello World"
'name_ne' => 'Hello World', // name != "Hello World"
'name_notnull' => null, // name is not null
'description_null' => null, // description is null
'description_notlike' => 'Hello World', // description NOT LIKE '%Hello World%'
'description_like' => 'Hello World', // description LIKE '%Hello World%'
'name_prefix' => 'Hello', // name LIKE 'Hello%'
];
Rancher::stack()->filter($params)->get();