PHPackages                             kfreiman/php-cli-docker-example - 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. [CLI &amp; Console](/categories/cli)
4. /
5. kfreiman/php-cli-docker-example

ActiveProject[CLI &amp; Console](/categories/cli)

kfreiman/php-cli-docker-example
===============================

Symfony console example application using docker and mysql

00PHP

Since Nov 28Pushed 7y ago1 watchersCompare

[ Source](https://github.com/kfreiman/php-cli-docker-example)[ Packagist](https://packagist.org/packages/kfreiman/php-cli-docker-example)[ RSS](/packages/kfreiman-php-cli-docker-example/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Symfony console example
=======================

[](#symfony-console-example)

This is basic example of usage Symfony console with Docker and database (DBAL without ORM). There is only one `CountDomainsCommand` which iterates over `users` table and counts how many users are using each email domain.

How To Run
----------

[](#how-to-run)

Run the database via Docker Compose: `docker-compose up -d`. It will launch MySQL server with schema and data placed in project's [mysql-dump](mysql-dump) directory.

Since the base is launched, build localy docker image of this app.

```
docker build -t kfreiman/php-cli-docker-example .
```

Note, in [Dockerfile](Dockerfile) used [multi-stage build](https://docs.docker.com/develop/develop-images/multistage-build/) to minimize size of container.

Finally, you can run the app.

```
docker run \
  --link=mysql_test_db:db \
  --network=custom_network \
  -e MYSQL_DATABASE=test_db \
  -e MYSQL_USER=test_user \
  -e MYSQL_PASSWORD=secret \
  -e batch=3 \
  kfreiman/php-cli-docker-example
```

To access the database container from app's container, you must specify `--link` parameter and enviroment variables from `docker-compose.yml`. Parameter `--network` is needed to run the container on the same network which as Docker Compose. `-e batch=3` defines batch size per table's query iteration, it's equal `1000` by default.

It will prints count of users, which uses certain domain:

```
5 domain1.com
4 domain4.com
2 domain2.com
1 domain3.com
```

Possible Future Improvements
----------------------------

[](#possible-future-improvements)

- Use entrypoint to able run different commands
- Use lock table or updated\_at mark for cases the table is big and some changes is possible during the command execution
- Implement tests
- Show progress during execution

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

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/4507eb0e7abf6bfde893d8daa17e141281062909eefd9450e63fa31dee94cfa4?d=identicon)[k.freiman](/maintainers/k.freiman)

---

Top Contributors

[![kfreiman](https://avatars.githubusercontent.com/u/2056294?v=4)](https://github.com/kfreiman "kfreiman (1 commits)")

### Embed Badge

![Health badge](/badges/kfreiman-php-cli-docker-example/health.svg)

```
[![Health](https://phpackages.com/badges/kfreiman-php-cli-docker-example/health.svg)](https://phpackages.com/packages/kfreiman-php-cli-docker-example)
```

###  Alternatives

[illuminate/console

The Illuminate Console package.

13046.0M6.4k](/packages/illuminate-console)[styleci/cli

The CLI tool for StyleCI

71470.5k9](/packages/styleci-cli)[winbox/args

Windows command-line formatter

20720.9k21](/packages/winbox-args)[macopedia/magento2-categoryimporter

Category Importer for Magento 2

344.7k](/packages/macopedia-magento2-categoryimporter)

PHPackages © 2026

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