diff --git a/.gitignore b/.gitignore index 2dc36f94..228f5459 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ vendor/ bin/ composer.lock .vagrant +/.php_cs.cache diff --git a/.php_cs b/.php_cs new file mode 100644 index 00000000..3eaf3dae --- /dev/null +++ b/.php_cs @@ -0,0 +1,38 @@ +in([ + __DIR__.'/src', + __DIR__.'/tests', + ]) + ->notPath('/fixtures/') +; + +return \PhpCsFixer\Config::create() + ->setRules([ + '@Symfony' => true, + '@Symfony:risky' => true, + '@PHP56Migration' => true, + '@PHP56Migration:risky' => true, + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + 'array_syntax' => [ + 'syntax' => 'short' + ], + 'combine_consecutive_unsets' => true, + 'declare_strict_types' => true, + 'linebreak_after_opening_tag' => true, + 'modernize_types_casting' => true, + 'native_function_invocation' => true, + 'no_php4_constructor' => true, + 'ordered_imports' => true, + 'php_unit_strict' => true, + 'phpdoc_order' => true, + 'strict_comparison' => true, + 'strict_param' => true, + ]) + ->setRiskyAllowed(true) + ->setFinder($finder) +; diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 00000000..60d211bf --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,11 @@ +filter: + paths: [src/*] +checks: + php: + code_rating: true + duplication: true +tools: + external_code_coverage: true + php_code_sniffer: + config: + standard: "PSR2" diff --git a/.travis.yml b/.travis.yml index f498bdd7..41708d6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,24 +1,68 @@ -language: go +language: php sudo: required services: - docker +cache: + directories: + - $HOME/.composer/cache + +php: 7.2 + env: + global: + - TEST_COMMAND="composer test" matrix: - - SYMFONY_VERSION="2.3.*" - - SYMFONY_VERSION="2.7.*" + - DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.01.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.35 DOCKER_VERSION=17.12.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.34 DOCKER_VERSION=17.11.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.33 DOCKER_VERSION=17.10.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.32 DOCKER_VERSION=17.09.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.31 DOCKER_VERSION=17.07.0~ce-0~ubuntu + - DOCKER_API_VERSION=1.30 DOCKER_VERSION=17.06.2~ce-0~ubuntu + - DOCKER_API_VERSION=1.29 DOCKER_VERSION=17.05.0~ce-0~ubuntu-trusty + - DOCKER_API_VERSION=1.28 DOCKER_VERSION=17.04.0~ce-0~ubuntu-trusty + - DOCKER_API_VERSION=1.27 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty + - DOCKER_API_VERSION=1.26 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty + - DOCKER_API_VERSION=1.25 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty + +matrix: + allow_failures: + - php: hhvm + fast_finish: true + include: + - php: 7.1 + sudo: required + services: + - docker + env: DOCKER_API_VERSION=1.25 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" + - php: 7.1 + env: DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu TEST_COMMAND="composer lint" + - php: 7.2 + sudo: required + services: + - docker + env: DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu before_install: - sudo apt-get update - - sudo apt-get install -y php5-cli - - curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer + - sudo apt-cache madison docker-ce + - sudo apt-get -o Dpkg::Options::="--force-confnew" install -y --force-yes docker-ce=${DOCKER_VERSION} + - travis_retry composer self-update install: - - COMPOSER_ROOT_VERSION=dev-master composer --prefer-source install + - travis_retry composer install + - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction + - travis_retry composer require docker-php/docker-php-api:4.${DOCKER_API_VERSION}.* script: - - bin/phpunit + - $TEST_COMMAND + +after_success: + - if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi + - if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi after_script: - sudo cat /var/log/upstart/docker.log diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..b3b5716d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,14 @@ +# Changelog + +## 2.0 + + - [BC Break] All endpoints have new names and potentially new parameters + - Add async (with amp artax) support + - It now uses the official swagger specification of docker + - Allow to use from 1.25 to 1.36 api version of Docker + - Add support for more keywords in ContextBuilder + - Lot of bug fixes + +## 1.24.0 - 08/08/2014 + + - [BC Break] Listing containers now return `ContainerInfo` object (instead of `ContainerConfig`) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..6be589b9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,94 @@ +# Contributing + +If you're here, you would like to contribute to this repository and you're really welcome! + + +## Bug reports + +If you find a bug or a documentation issue, please report it or even better: fix it :). If you report it, +please be as precise as possible. Here is a little list of required information: + + - Precise description of the bug + - Details of your environment (for example: OS, PHP version, installed extensions) + - Backtrace which might help identifying the bug + + +## Feature requests + +If you think a feature is missing, please report it or even better: implement it :). If you report it, describe the more +precisely what you would like to see implemented and we will discuss what is the best approach for it. If you can do +some research before submitting it and link the resources to your description, you're awesome! It will allow us to more +easily understood/implement it. + + +## Sending a Pull Request + +If you're here, you are going to fix a bug or implement a feature and you're the best! To do it, first fork the repository, clone it and create a new branch with the following commands: + +``` bash +$ git clone git@github.com:your-name/docker-php.git +$ git checkout -b feature-or-bug-fix-description +``` + +Then install the dependencies through [Composer](https://getcomposer.org/): + +``` bash +$ composer install +``` + +Write code and tests. When you are ready, run the tests. (This is usually [PHPUnit](http://phpunit.de/) or [PHPSpec](http://phpspec.net/)) + +``` bash +$ composer test +``` + +When you are ready with the code, tested it and documented it, you can commit and push it with the following commands: + +``` bash +$ git commit -m "Feature or bug fix description" +$ git push origin feature-or-bug-fix-description +``` + +**Note:** Please write your commit messages in the imperative and follow the [guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for clear and concise messages. + +Then [create a pull request](https://help.github.com/articles/creating-a-pull-request/) on GitHub. + +Please make sure that each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting with the following commands (here, we assume you would like to squash 3 commits in a single one): + +``` bash +$ git rebase -i HEAD~3 +``` + +If your branch conflicts with the master branch, you will need to rebase and repush it with the following commands: + +``` bash +$ git remote add upstream git@github.com:docker-php/docker-php.git +$ git pull --rebase upstream master +$ git push -f origin feature-or-bug-fix-description +``` + +## Internal + +This library consist, for the most part, of auto generated code where the reference is an [Open API Specification (Swagger v2)](https://openapis.org/). In order to modify API +endpoint or requested / returned object, you will need to update the `docker-swagger.json` file instead of files in the `generated` directory. + +There is a bash script at the root of this repository `generate.sh` which helps launching the command to generate files according to the +specification. + +When changing the specification don't hesitate to do 2 commits for better reading: + + * One with only changes to the specification + * One with changes on the generated code + +Having this also helps backporting changes to the specification in previous versions. + + +## Coding standard + +This repository follows the [PSR-2 standard](http://www.php-fig.org/psr/psr-2/) and so, if you want to contribute, +you must follow these rules. + + +## Semver + +We are trying to follow [semver](http://semver.org/). When you are making BC breaking changes, please let us know why you think it is important. In this case, your patch can only be included in the next major version. diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..b5b4ca44 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2013 Geoffrey Bachelet and +contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md index 9aa7f18a..27464be6 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,48 @@ -Docker PHP -========== - -**Docker PHP** (for lack of a better name) is a [Docker](http://docker.com/) client written in PHP. This library is still a work in progress. Not much is supported yet, but the goal is to reach 100% API support. - -The test suite currently passes against the [Docker Remote API v1.20](http://docs.docker.com/reference/api/docker_remote_api_v1.20/). +# No longer maintained -[![Documentation Status](https://readthedocs.org/projects/docker-php/badge/?version=latest)](http://docker-php.readthedocs.org/en/latest/) [![Travis-CI](https://travis-ci.org/stage1/docker-php.svg?branch=master)](https://travis-ci.org/stage1/docker-php) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/stage1/docker-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/stage1/docker-php/?branch=master) +I'm backing off maintaining this library due to a lack of motivation, time and usage of docker, contact me on twitter https://twitter.com/joelwurtz if you wish to take over this repository (or just do a fork). -Versioning ----------- - -There is no *stable* version yet and the API is rapidly evolving, but we still try to semantically version the library according to [semver](http://semver.org/), but shifted a little bit: +Docker PHP +========== -* **MAJOR** version number stays to 0 until API freeze -* **MINOR** version number is incremented when a backward incompatible change is made -* **PATCH** version number is incremented when a new feature is added +**Docker PHP** (for lack of a better name) is a [Docker](http://docker.com/) client written in PHP. +This library aim to reach 100% API support of the Docker Engine. -So basically, if you want the `0.5` version set, use a version constraint of `~0.5.0` and you should be fine. +The test suite currently passes against Docker Remote API v1.25 to v1.36. -We are **NOT** documenting upgrade procedures until we reach a stable API, please read the code and PRs to keep up with what's going on. You can also ask us for help, we're nice people! +[![Documentation Status](https://readthedocs.org/projects/docker-php/badge/?version=latest)](http://docker-php.readthedocs.org/en/latest/) +[![Latest Version](https://img.shields.io/github/release/docker-php/docker-php.svg?style=flat-square)](https://github.com/docker-php/docker-php/releases) +[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) +[![Build Status](https://img.shields.io/travis/docker-php/docker-php.svg?branch=master&style=flat-square)](https://travis-ci.org/docker-php/docker-php) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/docker-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/docker-php/docker-php) +[![Quality Score](https://img.shields.io/scrutinizer/g/docker-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/docker-php/docker-php) +[![Total Downloads](https://img.shields.io/packagist/dt/docker-php/docker-php.svg?style=flat-square)](https://packagist.org/packages/docker-php/docker-php) +[![#docker-php on Slack](http://slack.httplug.io/badge.svg)](http://slack.httplug.io) Installation ------------ The recommended way to install Docker PHP is of course to use [Composer](http://getcomposer.org/): -```json -{ - "require": { - "stage1/docker-php": "@dev" - } -} +```bash +composer require docker-php/docker-php ``` -**Note**: there is no stable version of Docker PHP yet. +Docker API Version +------------------ + +By default it will use the last version of docker api available, if you want to fix a version (like 1.25) you can add this +requirement to composer: + +```bash +composer require "docker-php/docker-php-api:4.1.25.*" +``` Usage ----- See [the documentation](http://docker-php.readthedocs.org/en/latest/). -Using Vagrant -------------- - -The provisioning included does not run the `composer install` bit, so you'll have to do it yourself: - -``` -$ vagrant up --provider=virtualbox -$ vagrant ssh -$ cd /vagrant; composer install --dev -``` - Unit Tests ---------- @@ -63,60 +55,20 @@ $ composer install --dev Run it using [PHPUnit](http://phpunit.de/): ``` -$ bin/phpunit +$ composer test ``` Contributing ------------ -Here are a few rules to follow in order to ease code reviews, and discussions before maintainers accept and merge your work. - -* You **MUST** follow the [PSR-1](http://www.php-fig.org/psr/1/) and [PSR-2](http://www.php-fig.org/psr/2/). -* You **MUST** run the test suite. -* You **MUST** write (or update) unit tests. -* You **SHOULD** write documentation. - -Please, write [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html), and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) before submitting your Pull Request. - -One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html) too. This is used to "clean" your Pull Request before merging it (we don't want commits such as `fix tests`, `fix 2`, `fix 3`, etc.). - -Also, when creating your Pull Request on GitHub, you **MUST** write a description which gives the context and/or explains why you are creating it. - -Thank you! +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. Credits ------- This README heavily inspired by [willdurand/Negotiation](https://github.com/willdurand/Negotiation) by @willdurand. This guy is pretty awesome. -Projects --------- - -Projects known to be using docker-php: - -* [JoliCi](https://github.com/jolicode/JoliCi), Run your tests on different and isolated stacks - License ------- -The MIT License (MIT) - -Copyright (c) 2013 Geoffrey Bachelet - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +The MIT License (MIT). Please see [License File](LICENSE) for more information. diff --git a/Vagrantfile b/Vagrantfile deleted file mode 100644 index 18c74477..00000000 --- a/Vagrantfile +++ /dev/null @@ -1,27 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -$script = <