Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Componenta App Console

Console runtime integration for Componenta applications. The package connects componenta/app with Symfony Console, registers console boot targets, provides a command registry, and contributes framework maintenance commands.

Use this package when an application has CLI commands. It does not provide the base application kernel; that belongs to componenta/app.

Installation

composer require componenta/app-console

The package exposes Componenta\App\Console\ConfigProvider through Composer metadata, so componenta/composer-plugin can add it to the generated provider file.

Dependencies

The package requires PHP ^8.4, componenta/app, componenta/class-finder, componenta/config, componenta/di, componenta/error-handler, componenta/path-resolver, componenta/reflection, componenta/var-export, PSR-11, PSR-3, Symfony Console, Symfony EventDispatcher, and Symfony Lock.

Registered Services

ConfigProvider registers:

Service or config key Purpose
ConfigKey::APP_BY_SCOPE[Scope::CLI->value] Resolves the CLI scope directly to App::class.
ConsoleBootTargetAdapter Adapts the console application to a boot target.
ConsoleBootloader Boots console commands into the target registry.
ConsoleCommandRegistryInterface Alias to ConsoleCommandRegistry.
EventDispatcherFactoryInterface Factory for Symfony Console event dispatchers.
ConfigKey::COMMANDS List of command service ids registered by packages or the application.

Runtime Behavior

ConsoleBootloader runs in console scope. It reads all configured command service ids from Componenta\App\Console\ConfigKey::COMMANDS, resolves them from the container, and registers them in the Symfony Console application.

In development mode it also scans the class iterator for Symfony #[AsCommand] attributes. Attribute-discovered commands are skipped when the same class was already registered through config. In production mode command discovery is disabled; commands must be present in the built configuration.

Application-local commands can be registered from config/console.php when that file is loaded by the application config graph:

use App\Console\ImportPostsCommand;
use Componenta\App\Console\ConfigKey;

return [
    ConfigKey::COMMANDS => [
        ImportPostsCommand::class,
    ],
];

Packages should contribute commands from their own ConfigProvider by appending to the same key.

Maintenance Commands

The package registers these commands:

Command Purpose
app:build Writes config and container caches, collects known autowiring roots from build contributors, and emits lazy content-addressed factory shards. Must run with APP_ENV=development.
app:preload Generates preload.php from existing build cache artifacts.
app:cache:clear Clears build, development, and runtime cache directories. Use --build, --dev, or --runtime to limit the scope.

app:build creates a fresh source configuration and a cache-disabled build container from the conventional config/config.php. It does not merge the currently warmed development config into the result, so deleted routes, handlers, and compile-delta values cannot leak into a new production artifact.

Discovery finalizes once, then every listener compiler and configured cache contributor receives the same source snapshot. Empty arrays, null, and default false contribution values are omitted. A required version marker, such as the empty CQRS v2 map ['version' => 2], remains because it is not an empty section. Build-only registries and #[DevOnly] listeners are removed from production config; when no runtime listener remains, the discovery class table is omitted too.

Compiled factory definitions are merged into the normal dependencies.factories section; explicit application factories win. Shards are loaded on first use, and production performs no source hashing. Re-run app:build whenever providers, discovered PHP classes, routes, CQRS metadata, DI extension chains, or deployment dependencies change.

Public API

  • ConsoleCommandRegistryInterface stores command definitions for the console application.
  • ConsoleBootTargetInterface is the boot target for packages that want to add commands.
  • InputFactoryInterface, OutputFactoryInterface, and IOFactory adapt Symfony Console input and output.
  • ConfigKey::COMMANDS is the production-safe command registration point.

Related Packages

About

Console runtime integration for Componenta applications

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages