1. Go to this page and download the library: Download axy/docker-compose-config 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/ */
axy / docker-compose-config example snippets
use axy\docker\compose\config\ComposeConfig;
// data loading is a matter of external code
$data = Yaml::parse(file_get_contents('docker-compose.yml'));
$config = new ComposeConfig($data);
// manipulation
$service = $config->services->create('php');
$service->build->context = './build';
// ...
// data saving is a matter of external code
$data = $config->getData();
$yaml = Yaml::dump($data, 5);
file_put_contents('docker-compose.yml', $yaml);
$config->services['db']->disable(); // disable service "db"
$php = $config->services->create('php'); // create empty service php
$www = $config->services->create('www', ['image' => 'nginx']); // create service based on loaded config
$config->services['php']->build->context = './build'; // get service by name
$config->services->disableService('db'); // disable services if it exists
$config->services->clear(); // clear the service list
// Base template
$service->volumes->add('./app:/var/www/app'); // bind volume without key
$service->volumes->add('./log:/var/log/nginx', 'nginx_log'); // with key "nginx_log"
// ...
// I want disable mount nginx log
$service->volumes->getByKey('nginx_log')->disable();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.