Skip to content
This repository was archived by the owner on Oct 26, 2019. It is now read-only.
This repository was archived by the owner on Oct 26, 2019. It is now read-only.

New structure proposal #46

@gsouf

Description

@gsouf

Everything is available in my fork : https://github.com/SneakyBobito/docker-php but please read the following before.

Introduction

I have a proposal for a new way to implement commands in docker-php. I think that such a way would allow to make it really easyer to implement. It is also more semantic and much more clean.

It is though to be 100% extendable and rewrittable by extending classes. Then even the most complexe api endpoint that mays need complexe stuff can be implemented in this way.

Please be aware that this will break a few compatibility with previous versions.

No test has been written or updated for the moment

About the new command structure

Each command is one class. The class is named to reflect the api endpoint.

E.G POST /containers/create is available through the class Docker\Command\Post\Containers\Create

Each of these classes extend Docker\Command\AbstractCommand : https://github.com/SneakyBobito/docker-php/blob/master/src/Docker/Command/AbstractCommand.php

It offers a common way to call them for a given docker instance. $command->run($dockerInstance);

The run command returns an object that wraps the request, the response and an ouput specific to the command. If an error happens, then it returns an exception

I placed a little doccumentation about this implementation. Not sure it is very understandable at the first reading but it allows to have all in one place :
https://github.com/SneakyBobito/docker-php/blob/master/doc/internal/command.md

What did i change too

  • I added the property apiVersion to the Docker\Docker class. That allows to build such url : /v1.10/containers/create
  • I changed the constructor of Docker\Manager\ContainerManager to pass the docker instance instead of the docker client. Then it allows to call the new command structure directly from the Manager (because commands need a Docker\Docker instance, and not a http client instance)

Please if something is obscure to you feel free to ask me.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions