This document provides a comprehensive overview of all commands available in the MageForge module. It's designed to help developers understand the structure and functionality of each command.
All commands in MageForge follow a consistent structure based on Symfony's Console Component. They extend the Symfony\Component\Console\Command\Command
class and implement:
- A constructor that injects dependencies
- A
configure()
method that sets the command name, description, and arguments/options - An
execute()
method that handles the command logic
Purpose: Lists all available Magento themes in the installation.
File: /src/Console/Command/ListThemeCommand.php
Dependencies:
ThemeList
- Service to retrieve theme information
Usage:
bin/magento mageforge:theme:list
Implementation Details:
- Retrieves all themes from the
ThemeList
service - Displays a formatted table with theme information (code, title, path)
- Returns success status code
Purpose: Builds specified Magento themes by compiling assets and deploying static content.
File: /src/Console/Command/BuildThemeCommand.php
Dependencies:
ThemePath
- Service to resolve theme pathsThemeList
- Service to retrieve theme informationBuilderPool
- Service to get appropriate builders for themes
Usage:
bin/magento mageforge:theme:build [<themeCodes>...]
Implementation Details:
- If no theme codes are provided, displays an interactive prompt to select themes
- For each selected theme:
- Resolves the theme path
- Determines the appropriate builder for the theme type
- Executes the build process
- Displays a summary of built themes and execution time
- Has an alias:
frontend:build
Purpose: Watches theme files for changes and automatically rebuilds when changes are detected.
File: /src/Console/Command/ThemeWatchCommand.php
Dependencies:
BuilderPool
- Service to get appropriate builders for themesThemeList
- Service to retrieve theme informationThemePath
- Service to resolve theme paths
Usage:
bin/magento mageforge:theme:watch [--theme=THEME]
Implementation Details:
- If no theme code is provided, displays an interactive prompt to select a theme
- Resolves the theme path
- Determines the appropriate builder for the theme type
- Starts a watch process that monitors for file changes
- Has an alias:
frontend:watch
Purpose: Displays system information relevant to Magento development.
File: /src/Console/Command/SystemCheckCommand.php
Dependencies:
ProductMetadataInterface
- For retrieving Magento versionEscaper
- For HTML escaping output
Usage:
bin/magento mageforge:system:check
Implementation Details:
- Retrieves and displays:
- PHP version
- Node.js version (with comparison to latest LTS)
- MySQL version
- Operating System information
- Magento version
- Utilizes Symfony's table component for formatted output
Purpose: Displays the current and latest version of the MageForge module.
File: /src/Console/Command/VersionCommand.php
Dependencies:
File
- Filesystem driver for reading files
Usage:
bin/magento mageforge:version
Implementation Details:
- Reads the current module version from
composer.lock
- Fetches the latest version from GitHub API
- Displays both versions for comparison
The commands rely on several services for their functionality:
BuilderPool
: Manages theme builders and selects appropriate builders for themesBuilderInterface
: Implemented by all theme buildersMagentoStandard\Builder
: Processes standard Magento LESS-based themes- Various other builders for different theme types
ThemeList
: Retrieves all installed themesThemePath
: Resolves theme codes to filesystem pathsStaticContentDeployer
: Handles static content deploymentCacheCleaner
: Manages cache cleaning after theme builds
DependencyChecker
: Verifies required dependencies for theme buildingGruntTaskRunner
: Executes Grunt tasks for theme compilation
- The command is executed via the Magento CLI framework
- Dependencies are injected via constructor
- Arguments and options are processed
- Interactive prompts are shown if required
- The appropriate services are called to perform the command's task
- Formatted output is displayed to the user
- A status code is returned (success or failure)
All commands implement error handling via try-catch blocks and return appropriate error messages and status codes when failures occur. Interactive commands also provide suggestions for resolving issues.