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 10mo 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 1mo ago

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

19

—

LowBetter than 10% of packages

Maintenance40

Moderate activity, may be stable

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

[deployer/deployer

Deployment Tool

11.0k25.4M207](/packages/deployer-deployer)[appwrite/server-ce

End to end backend server for frontend and mobile apps.

55.3k84.2k](/packages/appwrite-server-ce)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[felixfbecker/language-server-protocol

PHP classes for the Language Server Protocol

22476.7M6](/packages/felixfbecker-language-server-protocol)[heroku/heroku-buildpack-php

Toolkit for starting a PHP application locally, with or without foreman, using the same config for PHP and Apache2/Nginx as on Heroku

8161.3M10](/packages/heroku-heroku-buildpack-php)[tiamo/phpas2

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

4674.7k](/packages/tiamo-phpas2)

PHPackages © 2026

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