MakeCommand
- Full name:
\Codefy\Framework\Console\Commands\MakeCommand - Parent class:
\Codefy\Framework\Console\ConsoleCommand - Warning: this class is deprecated. This means that this class will likely be removed in a future version.
See Also:
- \Codefy\Framework\Console\Commands\Domain\MakeDomainCommand
- \Codefy\Framework\Console\Commands\Domain\MakeCommand
- https://codefyphp.com/docs/getting-started/codex/
Constants
| Constant | Visibility | Type | Value |
|---|---|---|---|
FILE_EXTENSION | protected | '.php' | |
STUBS | private | ['controller' => 'App\Infrastructure\Http\Controllers', 'repository' => 'App\Infrastructure\Persistence\Repository', 'provider' => 'App\Infrastructure\Providers', 'middleware' => 'App\Infrastructure\Http\Middleware', 'error' => 'App\Infrastructure\Errors', 'command' => 'App\Application\Console\Commands', 'route' => 'App\Infrastructure\Http\Routes'] |
Properties
errors
comments
info
name
description
help
args
Refers to name, type, description argument.
options
Refers to name, shortcut, type, description and default.
Methods
handle
Inherited methods
__construct
Parameters:
| Parameter | Type | Description |
|---|---|---|
$codefy | \Codefy\Framework\Application |
configure
Configure commands.
execute
protected execute(\Symfony\Component\Console\Input\InputInterface $input, \Symfony\Component\Console\Output\OutputInterface $output): int
Parameters:
| Parameter | Type | Description |
|---|---|---|
$input | \Symfony\Component\Console\Input\InputInterface | |
$output | \Symfony\Component\Console\Output\OutputInterface |
Throws:
getArgument
Returns the argument value for the given argument name.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string|null |
getOptions
Returns the option value for the given option name.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string|null |
terminalRaw
Outputs the string to the console without any tag.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$string | string |
terminalInfo
Output to the terminal wrap in info tags.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$string | string |
terminalComment
Output to the terminal wrap in comment tags.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$string | string |
terminalQuestion
Output to the terminal wrap in question tags.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$string | string |
terminalError
Output to the terminal wrap in error tags.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$string | string |
terminalNewLine
Output to the terminal with a blank line.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$count | int |
confirm
Parameters:
| Parameter | Type | Description |
|---|---|---|
$question | string |
ask
Parameters:
| Parameter | Type | Description |
|---|---|---|
$question | string | |
$default | bool|float|int|string|null |
choice
protected choice(string $question, (string|bool|int|float|\Stringable)[] $choices, bool|float|int|string|null $default = null, string|null $message = null): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$question | string | |
$choices | (string|bool|int|float|\Stringable)[] | |
$default | bool|float|int|string|null | |
$message | string|null |
multiChoice
protected multiChoice(string $question, (string|bool|int|float|\Stringable)[] $choices, bool|float|int|string|null $default = null, string|null $message = null): mixed
Parameters:
| Parameter | Type | Description |
|---|---|---|
$question | string | |
$choices | (string|bool|int|float|\Stringable)[] | |
$default | bool|float|int|string|null | |
$message | string|null |
resolveCommand
Resolve the console command instance for the given command.
protected resolveCommand(\Symfony\Component\Console\Command\Command|string $command): \Symfony\Component\Console\Command\Command
Parameters:
| Parameter | Type | Description |
|---|---|---|
$command | \Symfony\Component\Console\Command\Command|string |
call
Call another console command.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$command | \Symfony\Component\Console\Command\Command|string | |
$arguments | array |
Throws:
option
Get the value of a command option.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$key | string|null |
options
Get all the options passed to the command.
runCommand
Run the given console command.
protected runCommand(\Symfony\Component\Console\Command\Command|string $command, array $arguments, \Symfony\Component\Console\Output\OutputInterface $output): int
Parameters:
| Parameter | Type | Description |
|---|---|---|
$command | \Symfony\Component\Console\Command\Command|string | |
$arguments | array | |
$output | \Symfony\Component\Console\Output\OutputInterface |
Throws:
createInputFromArguments
Create an input instance from the given arguments.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$arguments | array |
context
Get all the context passed to the command.
resolveResource
Parameters:
| Parameter | Type | Description |
|---|---|---|
$resource | string | |
$options | mixed |
Throws:
resolveClassNameSuffix
private resolveClassNameSuffix(string $classNameSuffix, string $classNamePrefix, mixed|null $options = null): void
Parameters:
| Parameter | Type | Description |
|---|---|---|
$classNameSuffix | string | |
$classNamePrefix | string | |
$options | mixed|null |
Throws:
createClassFromStub
Create the class file based on the stub file. Once the file is resolved and have a valid directory path and the stub content is properly filtered and change to reflect. Then and only then we will generate the actual usable class file.
public createClassFromStub(string $qualifiedClass, string|null $contentStream = null, string|null $classNameSuffix = null, string|null $flag = null, string|null $qualifiedNamespaces = null): void
Note. realpath will return false if the file or directory does not exist.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$qualifiedClass | string | |
$contentStream | string|null | |
$classNameSuffix | string|null | |
$flag | string|null | |
$qualifiedNamespaces | string|null | - will return the namespace for the stub command |
Throws:
addOptionalDirFlag
console command option flag. Use --dir={directory_name} to add a directory to the end of the filepath to create a subdirectory within a main directory
Parameters:
| Parameter | Type | Description |
|---|---|---|
$flag | string |
getStubFiles
Uses the php glob to retrieve all stub files form the relevant directory. Which will return an array of files within the specified directory with the [.stub] extension.
We then iterate over that array and uses php str_contain function to match a file from the array with the classNameSuffix. When we have a match then return the matching file string.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$classNameSuffix | string |
resolveStubContentPlaceholders
private resolveStubContentPlaceholders(string $file, string $classNameSuffix, string $classNamePrefix): array|bool
Parameters:
| Parameter | Type | Description |
|---|---|---|
$file | string | |
$classNameSuffix | string | |
$classNamePrefix | string |
resolveModelDependency
Resolve the model dependency by specifying which Stubs class will require a model.
Parameters:
| Parameter | Type | Description |
|---|---|---|
$classNamePrefix | string | |
$classNameSuffix | string |