Skip to content
Snippets Groups Projects
Commit 667767da authored by jurgenhaas's avatar jurgenhaas
Browse files

Change to a library and ensure coding standard.

parent 8b097bdb
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -5,39 +5,46 @@ namespace LakeDrops\DockerTraefik;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Yaml\Yaml;
/**
* Class Traefik.
*
* @package LakeDrops\DockerTraefik
*/
class Traefik {
/** @var string */
/**
* The name of the project using Traefik.
*
* @var string
*/
protected $name;
/** @var Filesystem */
protected $fs;
/**
* Traefik constructor.
*
* @param string $name
* Name of the network to be created which needs to match the container
* prefix of your project you would like to handle with Traefik.
* Name of the network to be created which needs to match the container
* prefix of your project you would like to handle with Traefik.
*/
public function __construct($name) {
$this->name = $name;
$this->fs = new Filesystem();
}
/**
* Update the Traefik container.
*/
public function update() {
// Update host wider traefik container
// Update host wider traefik container.
$traefikPath = $_SERVER['HOME'] . '/.traefik';
$traefikFile = $traefikPath . '/docker-compose.yml';
if ($this->fs->exists($traefikFile)) {
/* @var FileSystem $fs */
$fs = new Filesystem();
if ($fs->exists($traefikFile)) {
$traefik = Yaml::parse(file_get_contents($traefikFile));
}
else {
$this->fs->mkdir($traefikPath);
$fs->mkdir($traefikPath);
$traefik = [
'version' => '2',
'services' => [
......
......@@ -3,7 +3,7 @@
"description": "Library to prepare local Traefik Docker container which is used by e.g. Docker4Drupal.",
"type": "library",
"keywords": ["Drupal", "Development", "Docker"],
"homepage": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik",
"homepage": "https://gitlab.lakedrops.com/composer/library/docker-traefik",
"license": "GPL-2.0+",
"authors": [
{
......@@ -20,20 +20,25 @@
}
],
"support": {
"issues": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik/issues",
"source": "https://gitlab.lakedrops.com/composer/plugin/docker-traefik/tree/master"
"issues": "https://gitlab.lakedrops.com/composer/library/docker-traefik/issues",
"source": "https://gitlab.lakedrops.com/composer/library/docker-traefik/tree/master"
},
"require": {
"php": ">=5.6",
"symfony/filesystem": "^2",
"symfony/yaml": "^2"
"symfony/filesystem": "^3",
"symfony/yaml": "^3"
},
"require-dev": {
"composer/composer": "^1.5.0",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"drupal/coder": "^8.2",
"phpunit/phpunit": "^4.8.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
"autoload": {
"psr-4": {
"LakeDrops\\DockerTraefik\\": "src/"
"LakeDrops\\DockerTraefik\\": ""
}
},
"require-dev": {
"phpunit/phpunit": "^4.4.0"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
verbose="true"
>
<testsuites>
<testsuite name="docker-traefik">
<directory>./tests/</directory>
</testsuite>
</testsuites>
</phpunit>
<?php
/**
* @file
* Contains \LakeDrops\DockerTraefik\Tests\TraefikTest.
*/
namespace LakeDrops\DockerTraefik\Tests;
use LakeDrops\DockerTraefik\Traefik;
use PHPUnit\Framework\TestCase;
/**
* Tests composer library functionality.
*/
class TraefikTest extends TestCase {
static $name = 'docker-traefik';
/**
* Test if we can initialize the main class.
*/
public function testComposerInstallAndUpdate() {
$traefik = new Traefik('test');
$this->assertInstanceOf('LakeDrops\DockerTraefik\Traefik', $traefik);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment