denetorus / galaxy-application-console
Runs PHP controller actions from a command line. The selected controller receives parsed arguments and options.
Package info
github.com/Denetorus/GalaxyApplicationConsole
pkg:composer/denetorus/galaxy-application-console
Requires
- php: >=8.4
- denetorus/galaxy-application: ^0.1.0
- denetorus/galaxy-logging: ^0.3.0
- denetorus/galaxy-result: ^0.3.0
- denetorus/galaxy-routing: ^0.2.0
- denetorus/galaxy-validation: ^0.3.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-03 12:27:14 UTC
README
Runs PHP controller actions from a command line. The selected controller receives parsed arguments and options.
Русский · Architecture · MIT
Getting started
Requires PHP 8.4 or newer. Install version 0.1.0 from Packagist.
composer require denetorus/galaxy-application-console:0.1.0
From the source checkout, install dependencies and run
composer install php examples/console.php hello
Complete example examples/console.php.
Use App\Controller\Console under src/Controller/Console. Pass routingPrefix: '' inside the entry configuration to use native paths such as hello or tools:hello@alternate. With default settings commands use console:. Run list or help hello in native mode. Help inspects controller metadata without creating controllers or services. For options use --name=value and --flag. Repeated options produce arrays. -- ends option parsing. Actions return GResult. The entry script exits using its console code.
Validating a required option
Inside an action that receives CommandInput $input, validate an integer option and read its converted value.
use Galaxy\Validation\Rule\IntegerRule; // In the controller action $this->requireOption($input, 'count', new IntegerRule(strict: false, options: ['min' => 1])); if (!$this->result->isSuccess()) { return $this->result; } $count = $input->getOption('count');
With --count=3, $count is the integer 3. Missing required options use business code 4. Invalid values use business code 5. Both use console code 4.
The default stages prepare input, dispatch the request and present the shared result. Application settings and optional logging are configured through applicationConfig. Routing and controller discovery are configurable through entryConfig.