Skip to content

Services

A service describes one or more containers, plus the tasks that come with them. Register the ones you need on the RegisterServiceEvent, and the plugin does the rest.

Service What it gives you
PHPService / SymfonyService PHP application served by FrankenPHP or nginx + PHP-FPM, with a builder container and QA tasks
GoService Go application built and run from the mounted sources
RustService Cargo application, with clippy and rustfmt tasks
GoBuilder / RustBuilder One compiler container for a repository, declaring the applications it builds
BinaryRunService Runs one compiled binary, whatever produced it
PostgresService PostgreSQL, with a postgres:client task
MySQLService MySQL, with a mysql:client task
MariaDBService MariaDB, with a mariadb:client task
ClickhouseService ClickHouse and its keeper
RedisService Redis and the RedisInsight UI
RabbitMQService RabbitMQ and its management UI
ElasticsearchService Elasticsearch and Kibana
MailpitService SMTP catch-all with a web UI
RedirectionioAgentService redirection.io agent as a reverse proxy

The router is not in that list: it is global, shared by every project, and managed with the docker:router:* tasks rather than registered in castor.php.

All of them share the same fluent configuration API.

Registering a service

#[AsListener(RegisterServiceEvent::class)]
function register_service(RegisterServiceEvent $event)
{
    $event->addService(new RedisService());
}

Keep a variable when another service needs to reference it — a database linked to an application, or an application behind the redirection.io agent:

$postgres = new PostgresService();
$event->addService($postgres);

$event->addService(
    (new SymfonyService('app'))
        ->withDirectory(__DIR__)
        ->withDatabaseService($postgres)
);