MigrationGenerator
        
        extends BaseCommand
    
    
            
            in package
            
        
    
    
            
            uses
                            GeneratorTrait                    
    
Generates a skeleton migration file.
Table of Contents
Properties
- $commands : Commands
- $logger : LoggerInterface
- $arguments : array<string, string>
- The Command's Arguments
- $classNameLang : string
- Language string key for required class names.
- $component : string
- Component Name
- $description : string
- The Command's Description
- $directory : string
- File directory
- $group : string
- The Command's Group
- $name : string
- The Command's Name
- $namespace : string|null
- Namespace to use for class.
- $options : array<string, string>
- The Command's Options
- $template : string
- View template name for fallback
- $templatePath : string|null
- (Optional) View template path
- $usage : string
- The Command's Usage
Methods
- __construct() : mixed
- __get() : array<string, string>|Commands|LoggerInterface|string|null
- Makes it simple to access our protected properties.
- __isset() : bool
- Makes it simple to check our protected properties.
- getPad() : int
- Get pad for $key => $value array output
- run() : int|void
- Actually execute a command.
- setPad() : string
- Pads our string out so that all titles are the same length to nicely line up descriptions.
- showHelp() : void
- Show Help includes (Usage, Arguments, Description, Options).
- basename() : string
- Change file basename before saving.
- buildContent() : string
- Builds the contents for class being generated, doing all the replacements necessary, and alphabetically sorts the imports for a given template.
- buildPath() : string
- Builds the file path from the class name.
- call() : int|void
- Can be used by a command to run other commands.
- execute() : void
- Execute the command.
- generateClass() : void
- Generates a class file from an existing template.
- generateView() : void
- Generate a view file from an existing template.
- getNamespace() : string
- Gets the namespace from the command-line option, or the default namespace if the option is not set.
- getOption() : bool|string|null
- Gets a single command-line option. Returns TRUE if the option exists, but doesn't have a value, and is simply acting as a flag.
- parseTemplate() : string
- Performs pseudo-variables contained within view file.
- prepare() : string
- Prepare options and do the necessary replacements.
- qualifyClassName() : string
- Parses the class name and checks if it is already qualified.
- renderTemplate() : string
- Gets the generator view as defined in the `Config\Generators::$views`, with fallback to `$template` when the defined view does not exist.
- setEnabledSuffixing() : $this
- Allows child generators to modify the internal `$enabledSuffixing` flag.
- setHasClassName() : $this
- Allows child generators to modify the internal `$hasClassName` flag.
- setSortImports() : $this
- Allows child generators to modify the internal `$sortImports` flag.
- showError() : void
- A simple method to display an error with line/file, in child commands.
- generateFile() : void
- Handles writing the file to disk, and all of the safety checks around that.
- normalizeInputClassName() : string
Properties
$commands
        public
            Commands
    $commands
    
    
    
    
    
    
$logger
        public
            LoggerInterface
    $logger
    
    
    
    
    
    
$arguments
The Command's Arguments
        protected
            array<string, string>
    $arguments
     = ['name' => 'The migration class name.']
    
    
    
    
    
$classNameLang
Language string key for required class names.
        protected
            string
    $classNameLang
     = ''
    
    
    
    
    
$component
Component Name
        protected
            string
    $component
    
    
    
    
    
    
$description
The Command's Description
        protected
            string
    $description
     = 'Generates a new migration file.'
    
    
    
    
    
$directory
File directory
        protected
            string
    $directory
    
    
    
    
    
    
$group
The Command's Group
        protected
            string
    $group
     = 'Generators'
    
    
    
    
    
$name
The Command's Name
        protected
            string
    $name
     = 'make:migration'
    
    
    
    
    
$namespace
Namespace to use for class.
        protected
            string|null
    $namespace
     = null
        Leave null to use the default namespace.
$options
The Command's Options
        protected
            array<string, string>
    $options
     = ['--session' => 'Generates the migration file for database sessions.', '--table' => 'Table name to use for database sessions. Default: "ci_sessions".', '--dbgroup' => 'Database group to use for database sessions. Default: "default".', '--namespace' => 'Set root namespace. Default: "APP_NAMESPACE".', '--suffix' => 'Append the component title to the class name (e.g. User => UserMigration).']
    
    
    
    
    
$template
View template name for fallback
        protected
            string
    $template
    
    
    
    
    
    
$templatePath
(Optional) View template path
        protected
            string|null
    $templatePath
     = null
        We use special namespaced paths like:
CodeIgniter\Commands\Generators\Views\cell.tpl.php.
$usage
The Command's Usage
        protected
            string
    $usage
     = 'make:migration <name> [options]'
    
    
    
    
    
Methods
__construct()
    public
                    __construct(LoggerInterface $logger, Commands $commands) : mixed
    Parameters
- $logger : LoggerInterface
- $commands : Commands
__get()
Makes it simple to access our protected properties.
    public
                    __get(string $key) : array<string, string>|Commands|LoggerInterface|string|null
    Parameters
- $key : string
Return values
array<string, string>|Commands|LoggerInterface|string|null__isset()
Makes it simple to check our protected properties.
    public
                    __isset(string $key) : bool
    Parameters
- $key : string
Return values
boolgetPad()
Get pad for $key => $value array output
    public
                    getPad(array<string, string> $array, int $pad) : int
    Use setPad() instead.
Parameters
- $array : array<string, string>
- $pad : int
Tags
Return values
intrun()
Actually execute a command.
    public
                    run(array<string|int, mixed> $params) : int|void
    Parameters
- $params : array<string|int, mixed>
Return values
int|voidsetPad()
Pads our string out so that all titles are the same length to nicely line up descriptions.
    public
                    setPad(string $item, int $max[, int $extra = 2 ][, int $indent = 0 ]) : string
    Parameters
- $item : string
- $max : int
- $extra : int = 2
- 
                    How many extra spaces to add at the end 
- $indent : int = 0
Return values
stringshowHelp()
Show Help includes (Usage, Arguments, Description, Options).
    public
                    showHelp() : void
    basename()
Change file basename before saving.
    protected
                    basename(string $filename) : string
    Parameters
- $filename : string
Return values
stringbuildContent()
Builds the contents for class being generated, doing all the replacements necessary, and alphabetically sorts the imports for a given template.
    protected
                    buildContent(string $class) : string
    Parameters
- $class : string
Return values
stringbuildPath()
Builds the file path from the class name.
    protected
                    buildPath(string $class) : string
    Parameters
- $class : string
- 
                    namespaced classname or namespaced view. 
Return values
stringcall()
Can be used by a command to run other commands.
    protected
                    call(string $command[, array<int|string, string|null> $params = [] ]) : int|void
    Parameters
- $command : string
- $params : array<int|string, string|null> = []
Tags
Return values
int|voidexecute()
Execute the command.
    protected
                    execute(array<int|string, string|null> $params) : void
    use generateClass() instead
Parameters
- $params : array<int|string, string|null>
generateClass()
Generates a class file from an existing template.
    protected
                    generateClass(array<int|string, string|null> $params) : void
    Parameters
- $params : array<int|string, string|null>
generateView()
Generate a view file from an existing template.
    protected
                    generateView(string $view, array<int|string, string|null> $params) : void
    Parameters
- $view : string
- 
                    namespaced view name that is generated 
- $params : array<int|string, string|null>
getNamespace()
Gets the namespace from the command-line option, or the default namespace if the option is not set.
    protected
                    getNamespace() : string
    Can be overridden by directly setting $this->namespace.
Return values
stringgetOption()
Gets a single command-line option. Returns TRUE if the option exists, but doesn't have a value, and is simply acting as a flag.
    protected
                    getOption(string $name) : bool|string|null
    Parameters
- $name : string
Return values
bool|string|nullparseTemplate()
Performs pseudo-variables contained within view file.
    protected
                    parseTemplate(string $class[, array<int, string> $search = [] ][, array<int, string> $replace = [] ][, array<string, bool|string|null> $data = [] ]) : string
    Parameters
- $class : string
- 
                    namespaced classname or namespaced view. 
- $search : array<int, string> = []
- $replace : array<int, string> = []
- $data : array<string, bool|string|null> = []
Return values
string —generated file content
prepare()
Prepare options and do the necessary replacements.
    protected
                    prepare(string $class) : string
    Parameters
- $class : string
Return values
stringqualifyClassName()
Parses the class name and checks if it is already qualified.
    protected
                    qualifyClassName() : string
    Return values
stringrenderTemplate()
Gets the generator view as defined in the `Config\Generators::$views`, with fallback to `$template` when the defined view does not exist.
    protected
                    renderTemplate([array<string, mixed> $data = [] ]) : string
    Parameters
- $data : array<string, mixed> = []
Return values
stringsetEnabledSuffixing()
Allows child generators to modify the internal `$enabledSuffixing` flag.
    protected
                    setEnabledSuffixing(bool $enabledSuffixing) : $this
    Parameters
- $enabledSuffixing : bool
Return values
$thissetHasClassName()
Allows child generators to modify the internal `$hasClassName` flag.
    protected
                    setHasClassName(bool $hasClassName) : $this
    Parameters
- $hasClassName : bool
Return values
$thissetSortImports()
Allows child generators to modify the internal `$sortImports` flag.
    protected
                    setSortImports(bool $sortImports) : $this
    Parameters
- $sortImports : bool
Return values
$thisshowError()
A simple method to display an error with line/file, in child commands.
    protected
                    showError(Throwable $e) : void
    Parameters
- $e : Throwable
generateFile()
Handles writing the file to disk, and all of the safety checks around that.
    private
                    generateFile(string $target, string $content) : void
    Parameters
- $target : string
- 
                    file path 
- $content : string
normalizeInputClassName()
    private
                    normalizeInputClassName() : string