PHP code example of andreipetcu / docker-php

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

    

andreipetcu / docker-php example snippets




use AndreiPetcu\DockerPhp\Docker;
use AndreiPetcu\DockerPhp\DockerCompose;
use Symfony\Component\Process\ProcessBuilder;

$compose = new DockerCompose(new ProcessBuilder());
$compose->setPath('/path/to/project')
    ->setNamespace('awesome');

$docker = new Docker(new ProcessBuilder());

// All commands accept either a service as a string or an array of services
// and a verbose flag which defaults to false
$compose->build('nginx', true)
    ->start('nginx', true)
    ->restart('nginx', true)
    ->stop('nginx', true)
    ->destroy('nginx', true);

// Will ssh into awesome_nginx_1
$compose->start('nginx')
    ->docker($docker)
    ->ssh('nginx');

// Will ssh into the given container.
$docker->ssh('container');
bash
composer