PHPackages                             alchemy/lazy-command-bundle - 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. alchemy/lazy-command-bundle

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

alchemy/lazy-command-bundle
===========================

v0.1.0(10y ago)312.4k2MITPHP

Since Jul 27Pushed 10y ago11 watchersCompare

[ Source](https://github.com/alchemy-fr/lazy-command-bundle)[ Packagist](https://packagist.org/packages/alchemy/lazy-command-bundle)[ RSS](/packages/alchemy-lazy-command-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

lazy-command-bundle
===================

[](#lazy-command-bundle)

Bundle for better dependency injection with Symfony commands

Installing
----------

[](#installing)

As simple as running a command in your terminal:

`composer require alchemy/lazy-command-bundle`.

Of course, you will also need to have [Composer](https://getcomposer.org/) installed beforehand.

Usage
-----

[](#usage)

Just add the bundle to your kernel. For now, it's zero-config, hassle free proxy goodness.

Background
----------

[](#background)

Using commands as services in Symfony can be quite a pain as soon as your dependencies start using connections to various resources (database, message queues, what not...), as all commands have to be instantiated in order for a Symfony Console application to run properly.

This bundle is an attempt to solve this by replacing all the service dependencies of your commands by lazy proxies (using the excellent ProxyManager library), ensuring that external resources are only acquired as needed.

Another approach could be to mark the dependencies of your commands as lazy using Symfony DI's built-in features, but this approach is not optimal when your dependencies are re-used in multiple contexts (ie, a service that is used both by a console application and a web application) and a proxy is not required (or worse, is a performance penalty) in all contexts.

How it works
------------

[](#how-it-works)

The bundle adds a compiler pass to your service container's build process, replacing all service references by lazy proxies for services that are tagged with the `console.command` tag.

There is no performance penalty in HTTP contexts (unless you actually use your commands in your controllers, but you probably have bigger issues to worry about then).

There are no benchmarks for now, but proxifying your command dependencies is probably cheaper than actually acquiring external resources that won't be used.

Todo
----

[](#todo)

- Add configuration settings to "lazify" commands on an on-demand basis
- Proxify dependencies used in setter injections
- Add LICENCE (which is MIT in case you're wondering)
- Add tests
- Add CI (Travis, Scrutinizer)
- Add badges
- Add library to packagist
- Create first release

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3948d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2437286?v=4)[Benoît Burnichon](/maintainers/bburnichon)[@bburnichon](https://github.com/bburnichon)

![](https://www.gravatar.com/avatar/58d21270e5d40f7ee05bb875b2442496ffd38cec041f7fdcc507b8b040f7e7f8?d=identicon)[thibaud-evaneos](/maintainers/thibaud-evaneos)

![](https://www.gravatar.com/avatar/ee4bb6d5bcc2f9456b41090151c1c8fb288e8949994d965b03b7e25648d663f4?d=identicon)[nmaillat](/maintainers/nmaillat)

---

Top Contributors

[![aztech-dev](https://avatars.githubusercontent.com/u/93562568?v=4)](https://github.com/aztech-dev "aztech-dev (1 commits)")

### Embed Badge

![Health badge](/badges/alchemy-lazy-command-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/alchemy-lazy-command-bundle/health.svg)](https://phpackages.com/packages/alchemy-lazy-command-bundle)
```

###  Alternatives

[wp-cli/wp-cli

WP-CLI framework

5.1k17.2M320](/packages/wp-cli-wp-cli)[consolidation/annotated-command

Initialize Symfony Console commands from annotated command class methods.

22569.8M19](/packages/consolidation-annotated-command)[seld/cli-prompt

Allows you to prompt for user input on the command line, and optionally hide the characters they type

24725.8M17](/packages/seld-cli-prompt)[illuminate/console

The Illuminate Console package.

12944.1M5.1k](/packages/illuminate-console)[php-tui/php-tui

Comprehensive TUI library heavily influenced by Ratatui

589747.0k6](/packages/php-tui-php-tui)[codedungeon/php-cli-colors

Liven up you PHP Console Apps with standard colors

10210.1M26](/packages/codedungeon-php-cli-colors)

PHPackages © 2026

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