{"id":20540560,"url":"https://github.com/utopia-php/orchestration","last_synced_at":"2025-04-07T08:21:24.784Z","repository":{"id":42968782,"uuid":"380734696","full_name":"utopia-php/orchestration","owner":"utopia-php","description":"Lite \u0026 fast micro PHP abstraction library for container orchestration that is **easy to use**.","archived":false,"fork":false,"pushed_at":"2024-11-26T10:21:23.000Z","size":395,"stargazers_count":14,"open_issues_count":9,"forks_count":12,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-03-31T06:09:19.156Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-27T12:31:09.000Z","updated_at":"2024-11-26T10:21:09.000Z","dependencies_parsed_at":"2024-04-08T04:25:08.617Z","dependency_job_id":"0375ca45-1194-4b2e-acd4-a42219e9e0ef","html_url":"https://github.com/utopia-php/orchestration","commit_stats":{"total_commits":151,"total_committers":12,"mean_commits":"12.583333333333334","dds":0.6291390728476821,"last_synced_commit":"55f43513b3f940a3f4f9c2cde7682d0c2581beb0"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Forchestration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Forchestration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Forchestration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Forchestration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/orchestration/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247615385,"owners_count":20967184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-16T01:16:13.532Z","updated_at":"2025-04-07T08:21:24.759Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Utopia Orchestration\n\n[![Build Status](https://app.travis-ci.com/utopia-php/orchestration.svg?branch=main)](https://app.travis-ci.com/github/utopia-php/orchestration)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/orchestration.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)\n\nUtopia framework orchestration library is simple and lite library for abstracting the interaction with multiple container orchestrators. This library is aiming to be as simple and easy to learn and use. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nAlthough this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/orchestration\n```\n\n### Example\n```php\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n\nuse Utopia\\Orchestration\\Orchestration;\nuse Utopia\\Orchestration\\Adapter\\DockerCLI;\n\n// Initialise Orchestration with Docker CLI adapter.\n$orchestration = new Orchestration(new DockerCLI());\n\n// Pull the image.\n$orchestration-\u003epull('ubuntu:latest');\n\n// Launch a ubuntu container that doesn't end using the tail command.\n$containerID = $orchestration-\u003erun('ubuntu:latest', 'testContainer', ['tail', '-f', '/dev/null']);\n\n$stderr = '';\n$stdout = '';\n\n// Execute a hello world command in the container\n$orchestration-\u003eexecute($containerID, ['echo', 'Hello World!'], $stdout, $stderr);\n\n// Remove the container forcefully since it's still running.\n$orchestration-\u003eremove($containerID, true);\n```\n\n## Usage\n\n### Initialisation\n\nThere are currently two orchestrator adapters available and each of them has slightly different parameters:\n\n- ### DockerAPI\n    Directly communicates to the Docker Daemon using the Docker UNIX socket.\n\n    ```php\n    use Utopia\\Orchestration\\Orchestration;\n    use Utopia\\Orchestration\\Adapter\\DockerAPI;\n\n    $orchestration = new Orchestration(new DockerAPI($username, $password, $email));\n    ```\n    $username, $password and $email are optional and are only used to pull private images from Docker Hub.\n\n- ### DockerCLI\n    Uses the Docker CLI to communicate to the Docker Daemon.\n    ```php\n    use Utopia\\Orchestration\\Orchestration;\n    use Utopia\\Orchestration\\Adapter\\DockerCLI;\n\n    $orchestration = new Orchestration(new DockerCLI($username, $password));\n    ```\n    $username and $password are optional and are only used to pull private images from Docker Hub.\n\nOnce you have initialised your Orchestration object the following methods can be used:\n\n- ### Pulling an image\n    This method pulls the image requested from the orchestrators registry. It will return a boolean value indicating if the image was pulled successfully.\n\n    ```php\n    $orchestration-\u003epull('image:tag');\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `image` [String] [Required]\n\n        The image to pull from the registry.\n\n    \u003c/details\u003e\n    \u003cbr\u003e\n\n- ### Running a container\n    This method creates and runs a new container. On success, it will return a string containing the container ID. On failure, it will throw an exception.\n\n    ```php\n    $orchestration-\u003erun(\n        'image:tag',\n        'name',\n        ['echo', 'hello world!'],\n        'entrypoint',\n        'workdir',\n        ['tmp:/tmp:rw', 'cooldirectory:/home/folder:rw'],\n        ['ENV_VAR' =\u003e 'value'],\n        '/tmp',\n        ['label' =\u003e 'value'],\n        'hostname',\n        true,\n    );\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `image` [String] [Required]\n\n        The image to base the container off.\n\n    - `name` [String] [Required]\n\n        The name given to the container.\n\n    - `command` [Array]\n\n        The command to run in the container seperated into a array.\n    \n    - `entrypoint` [String]\n\n        The executable to run in the container.\n\n    - `workdir` [String]\n\n        The default directory in which the container commands will run.\n\n    - `volumes` [Array]\n\n        The volumes to attach to the container.\n    \n    - `env` [Array]\n\n        The environment variables to set in the container.\n    \n    - `mountFolder` [String]\n\n        A folder that will be automatically mounted to /tmp in the container\n\n    - `labels` [Array]\n\n        The labels to set on the container.\n\n    - `hostname` [String]\n\n        The hostname to set on the container.\n\n    - `remove` [Boolean]\n  \n        Whether to remove the container once it exits.\n\n    \u003c/details\u003e\n\n\n- ### Executing a command in a running container\n\n    This method executes a command in an already running container and returns a boolean value indicating if the command was executed successfully.\n\n    ```php\n    $stdout = '';\n    $stderr = '';\n\n    $orchestraton-\u003eexecute(\n        'container_id',\n        ['echo', 'Hello World!'],\n        $stdout,\n        $stderr,\n        ['VAR' =\u003e 'VALUE'],\n        10,\n    )\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `container_id` [String] [Required]\n\n        The ID of the container to execute the command in.\n    \n    - `command` [Array] [Required]\n\n        The command to execute in the container.\n\n    - `stdout` [String] [Reference]\n\n        The variable to store the stdout of the command in.\n\n    - `stderr` [String] [Reference]\n\n        The variable to store the stderr of the command in.\n\n    - `env` [Array]\n\n        The environment variables to set while executing the command.\n\n    - `timeout` [Integer]\n\n        The timeout in seconds to wait for the command to finish.\n\n    \u003c/details\u003e\n\n- ### Removing a container\n\n    This method removes a container and returns a boolean value indicating if the container was removed successfully.\n\n    ```php\n    $orchestration-\u003eremove('container_id', true);\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `container_id` [String] [Required]\n\n        The ID of the container to remove.\n\n    - `force` [Boolean]\n\n        Whether to remove the container forcefully.\n\n    \u003c/details\u003e\n\n- ### List containers\n    \n    This method returns an array of containers.\n\n    ```php\n    $orchestration-\u003elist(['label' =\u003e 'value']);\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `filters` [Array]\n\n        Filters to apply to the list of containers.\n\n    \u003c/details\u003e\n\n- ### List Networks\n    \n    This method returns an array of networks.\n\n    ```php\n    $orchestration-\u003elistNetworks();\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    This method has no parameters\n\n    \u003c/details\u003e\n\n- ### Create a Network\n    \n    This method creates a new network and returns a boolean value indicating if the network was created successfully.\n\n    ```php\n    $orchestration-\u003ecreateNetwork('name', false);\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `name` [String] [Required]\n\n        The name of the network.\n\n    - `internal` [Boolean]\n\n        Whether to set the network to be an internal network.\n\n    \u003c/details\u003e\n\n- ### Remove a Network\n\n    This method removes a network and returns a boolean value indicating if the network was removed successfully.\n\n    ```php\n    $orchestration-\u003eremoveNetwork('network_id');\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `network_id` [String] [Required]\n\n        The ID of the network to remove.\n\n    \u003c/details\u003e\n\n- ### Connect a container to a network\n\n    This method connects a container to a network and returns a boolean value indicating if the connection was successful.\n\n    ```php\n    $orchestration-\u003econnect('container_id', 'network_id');\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `container_id` [String] [Required]\n\n        The ID of the container to connect to the network.\n\n    - `network_id` [String] [Required]\n\n        The ID of the network to connect to.\n\n    \u003c/details\u003e\n\n- ### Disconnect a container from a network\n\n    This method disconnects a container from a network and returns a boolean value indicating if the removal was successful.\n\n    ```php\n    $orchestration-\u003edisconnect('container_id', 'network_id', false);\n    ```\n\n    \u003cdetails\u003e\n    \u003csummary\u003e\n    Parameters\n    \u003c/summary\u003e\n    \u003cbr\u003e\n\n    - `container_id` [String] [Required]\n\n        The ID of the container to disconnect from the network.\n\n    - `network_id` [String] [Required]\n\n        The ID of the network to disconnect from.\n\n    - `force` [Boolean]\n\n        Whether to disconnect the container forcefully.\n\n    \u003c/details\u003e\n\n\n## System Requirements\n\nUtopia Framework requires PHP 7.3 or later. We recommend using the latest PHP version whenever possible.\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Forchestration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Forchestration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Forchestration/lists"}