PHPackages                             theod02/castor-docker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [DevOps &amp; Deployment](/categories/devops)
4. /
5. theod02/castor-docker

ActiveLibrary[DevOps &amp; Deployment](/categories/devops)

theod02/castor-docker
=====================

Set of classes for using docker

07[1 PRs](https://github.com/TheoD02/castor-docker/pulls)PHP

Since May 25Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/TheoD02/castor-docker)[ Packagist](https://packagist.org/packages/theod02/castor-docker)[ RSS](/packages/theod02-castor-docker/feed)WikiDiscussions main Synced yesterday

READMEChangelogDependenciesVersions (3)Used By (0)

Castor Docker
=============

[](#castor-docker)

This repository contains a set of classes for interacting with Docker containers in PHP trough Castor.

Description
-----------

[](#description)

Classes and helpers provide you an API to interact with Docker containers in PHP.

Classes reflect the Docker CLI commands.

Some helper like `docker()->utils()->isRunningInsideContainer()` can be used to detect if the PHP script is running inside a Docker container.

Usage
-----

[](#usage)

```
import('composer://theod02/castor-class-task');

// context() can be provided to docker() to use a specific context (is not a required argument)
docker(context())->compose()->exec(
    service: 'my-service',
    args: ['ls', '-la'],
    user: 'www-data',
    workdir: '/var/www/html',
);
```

This repository provide a `RunnerTrait` that can be used to run commands automatically in a Docker container from host or from a Docker container directly.

Example classe for running `composer` commands :

```
class Composer
{
    use RunnerTrait {
        __construct as private __runnerTraitConstruct;
    }

    public function __construct(
        private readonly Context $context,
        ?string $workingDirectory = null
    ) {
        $this->addIf($workingDirectory, '--working-dir', $workingDirectory);
        $this->__runnerTraitConstruct($context);
    }

    protected function getBaseCommand(): string
    {
        return 'composer';
    }

    protected function allowRunningUsingDocker(): bool
    {
        return true;
    }

    public function createProject(string $name, string $path): Process
    {
        $this->add('create-project', $name, $path);

        return $this->runCommand();
    }

    public function install(): Process
    {
        return $this->add('install')->runCommand();
    }

    public function require(string|array $packages, bool $dev = false, bool $withDependencies = false): Process
    {
        $packages = is_string($packages) ? [$packages] : $packages;
        $this->addIf($dev, '--dev');
        $this->addIf($withDependencies, '--with-dependencies');

        return $this->add('require', ...$packages)->runCommand();
    }

    public function update(
        string|array|null $packages = null,
        bool $dev = false,
        bool $withDependencies = false
    ): Process {
        $packages = is_string($packages) ? [$packages] : ($packages ?? []);
        $this->addIf($dev, '--dev');
        $this->addIf($withDependencies, '--with-all-dependencies');

        return $this->add('update', ...$packages)->runCommand();
    }
}

function composer(?Context $context = null, ?string $workingDirectory = null): Composer
{
    return new Composer(context: $context ?? context(), workingDirectory: $workingDirectory);
}

// Usage
composer()->install();
composer()->require('symfony/console', dev: true);
```

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity22

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/010f50739c2371f0bbe9eb992f13e23f77cecf34c60fc76e7803fdf9c83ff0ab?d=identicon)[TheoD02](/maintainers/TheoD02)

---

Top Contributors

[![TheoD02](https://avatars.githubusercontent.com/u/72203064?v=4)](https://github.com/TheoD02 "TheoD02 (28 commits)")

### Embed Badge

![Health badge](/badges/theod02-castor-docker/health.svg)

```
[![Health](https://phpackages.com/badges/theod02-castor-docker/health.svg)](https://phpackages.com/packages/theod02-castor-docker)
```

###  Alternatives

[in2code/in2publish_core

Content publishing extension to connect stage and production server

40143.4k](/packages/in2code-in2publish-core)[tiamo/phpas2

PHPAS2 is a php-based implementation of the EDIINT AS2 standard

4778.9k](/packages/tiamo-phpas2)[wapmorgan/php-rpm-packager

RPM packager for PHP applications.

106.6k](/packages/wapmorgan-php-rpm-packager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
