Skip to content
PHP Ecosystem
Explore

AbstractScaffoldCommand

API reference › Scaffold › Console › Command › AbstractScaffoldCommand

abstract classPHPForge\Scaffold\Console\Command\AbstractScaffoldCommand
ExtendsSymfony\Component\Console\Command\Command
Sourcesrc/Console/Command/AbstractScaffoldCommand.php
7 subclasses

Runs a scaffold console command: validates its input, resolves the project root and reports a RuntimeException of the command body as a [scaffold] error.

MethodDescriptionDefined by
execute() protected finalValidates the input, resolves the project root and runs AbstractScaffoldCommand::handle().AbstractScaffoldCommand
handle() protected abstractRuns the command body against the project root and returns its exit code.AbstractScaffoldCommand
validate() protectedReturns whether the input is valid, writing the error to the error output when it is not.AbstractScaffoldCommand
final protected function execute(Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output): int

Validates the input, resolves the project root and runs AbstractScaffoldCommand::handle().

Parameters

ParameterTypeDescription
$inputSymfony\Component\Console\Input\InputInterfaceCommand input that may carry the global --working-dir option.
$outputSymfony\Component\Console\Output\OutputInterfaceConsole output that receives the command output and the error messages.

Returns

int: Exit code of AbstractScaffoldCommand::handle(); 1 when the project root is not found or a runtime error is reported; 2 when the input is invalid.

abstract protected function handle(Symfony\Component\Console\Input\InputInterface $input, PHPForge\Scaffold\Console\SymfonyOutputWriter $out, string $projectRoot): int

Runs the command body against the project root and returns its exit code.

Parameters

ParameterTypeDescription
$inputSymfony\Component\Console\Input\InputInterfaceCommand input.
$outPHPForge\Scaffold\Console\SymfonyOutputWriterOutput sink of the command.
$projectRootstringAbsolute path of the directory containing the project composer.json.

Returns

int: Exit code of the command.

Throws

  • RuntimeException: when the lock file or the project manifest cannot be read or written.
protected function validate(Symfony\Component\Console\Input\InputInterface $input, PHPForge\Scaffold\Console\SymfonyOutputWriter $out): bool

Returns whether the input is valid, writing the error to the error output when it is not.

Parameters

ParameterTypeDescription
$inputSymfony\Component\Console\Input\InputInterfaceCommand input.
$outPHPForge\Scaffold\Console\SymfonyOutputWriterOutput sink that receives the error message.

Returns

bool: true when the command may run, false otherwise.