PHP code example of te4g / docker-client

1. Go to this page and download the library: Download te4g/docker-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/ */

    

te4g / docker-client example snippets




e4g\DockerClient\DockerClient;

$client = DockerClient::create();

var_dump($client->containerList());

    
   
    return [
        'openapi-file' => __DIR__ . '/open-api.yaml',
        'namespace' => 'Vendor\Library\Generated',
        'directory' => __DIR__ . '/generated',
    ];
    

    

   mfony\Component\HttpClient\Psr18Client;
   
   $httpClient = (new Psr18Client())->withOptions([
   'base_uri' => 'http://localhost',
   'bindto' => '/var/run/docker.sock'
   ]);
   
   $dockerClient = Vendor\Library\Generated\Client::create(httpClient: $httpClient);
   
   $containers = $dockerClient->containerList();
   
   foreach ($containers as $container) {
   echo $container->getId() . "\n";
   }
    
bash
    php vendor/bin/jane-openapi generate