### Generate Documentation Site Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/documentation.md Navigate to the 'docs' directory and run npm commands to install dependencies and start the documentation development server. ```bash cd docs npm install npm run start ``` -------------------------------- ### Basic Customer Creation Example Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-create.md A simple example demonstrating how to create a customer with the minimum required information. ```bash n98-magerun2.phar customer:create foo@example.com password123 John Doe base ``` -------------------------------- ### Install from Existing Files with --noDownload Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/installer/install.md Use the `--noDownload` option to install Magento from a pre-existing copy in the specified installation folder, connecting to the given database. This is useful if you already have the Magento files downloaded. ```bash n98-magerun2.phar install --noDownload ``` -------------------------------- ### Docusaurus Local Preview Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Steps to install dependencies and start a local development server for previewing Docusaurus documentation. ```bash devd ssh cd docs npm install npm run start ``` -------------------------------- ### Interactive Magento Installation Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/installer/install.md Run the installer interactively to be prompted for necessary details. This is useful for manual setup. ```bash n98-magerun2.phar install ``` -------------------------------- ### Install Documentation Dependencies Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Install the necessary Node.js packages for the documentation site. ```bash npm install ``` -------------------------------- ### Example Unattended Installation with Specific Version Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/installer/install.md An example of a fully unattended installation for a specific Magento CE version, including database, sample data, and configuration parameters. Use the `--useDefaultConfigParams` option to leverage your YAML configuration. ```bash n98-magerun2.phar install --dbHost="localhost" --dbUser="mydbuser" --dbPass="mysecret" --dbName="magentodb" --installSampleData=yes --useDefaultConfigParams=yes --magentoVersionByName="magento-ce-2.0.0.0-dev-beta1" --installationFolder="magento2" --baseUrl="http://magento2.localdomain/" ``` -------------------------------- ### Get All URLs Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/sys-url-list.md Execute this command to list all product, category, and CMS page URLs. No additional setup is required beyond having n98-magerun2 installed. ```bash n98-magerun2.phar sys:url:list ``` -------------------------------- ### Start Basic MCP Server Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Starts the MCP server with default settings. This is the most basic way to expose commands. ```bash n98-magerun2.phar mcp:server:start ``` -------------------------------- ### Example n98-magerun2 Configuration Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/configuration.md This is an example configuration file for n98-magerun2, demonstrating how to set up autoloaders and custom commands or aliases. ```yaml autoloaders: # Namespace => path to your libs VendorPrefix: /path/to/VendorPrefix/src AnotherPrefix: /path/to/another-prefix commands: customCommands: - VendorPrefix\Magento\Command\MyCommand - AnotherPrefix\FooCommand - AnotherPrefix\BarCommand aliases: - "ccc": "cache:clean config" - "customer:create:cmuench": "customer:create c.muench@netz98.de test123456 Christian Münch" ``` -------------------------------- ### Install Project Dependencies with Composer Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Install all project dependencies using Composer. This command should be run after cloning the repository. ```bash composer install ``` -------------------------------- ### Install MageForge with Post-Install Check Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mageforge/mageforge-install.md Use this command for a standard installation of MageForge, which includes a post-installation compatibility check. ```bash n98-magerun2.phar mageforge:install ``` -------------------------------- ### Example: Add Customer Address with Defaults Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-add-address.md This example demonstrates adding a new address for a customer, setting it as both the default billing and shipping address. Ensure all required parameters like email, website, and address components are provided. ```shell n98-magerun2.phar customer:add-address foo@example.com base --firstname="John" --lastname="Doe" --street="Main Street 1" --city="Berlin" --country="DE" --postcode="10117" --telephone="1234567890" --default-billing --default-shipping ``` -------------------------------- ### Usage example for post-install hook Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/install-in-ddev.md After setting up the hook and script, you can execute n98-magerun2 using this command. ```bash ddev exec mr2 ``` -------------------------------- ### Start DDEV Environment Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/local-ddev-setup.md Run this command in the project root to build and start the Docker containers defined in your DDEV configuration. ```bash ddev start ``` -------------------------------- ### Preview Documentation Locally Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Start a local development server to preview the documentation with live updates. The server typically runs at http://localhost:3000. ```bash npm run start ``` -------------------------------- ### Display MCP Server Help Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Shows the help information for the mcp:server:start command, including available options and predefined command groups. ```bash n98-magerun2.phar mcp:server:start --help ``` -------------------------------- ### Customer Creation with Additional Fields Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-create.md This example shows how to create a customer and include additional custom fields such as taxvat and prefix. ```bash n98-magerun2.phar customer:create foo@example.com passworD123 John Doe base taxvat DE12345678 prefix Mrs. ``` -------------------------------- ### Example Configuration Output Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/magerun/magerun-config-dump.md This is an example of the YAML output generated by the magerun:config:dump command, showing various configuration sections. ```yaml application: check-root-user: true twig: baseDirs: null plugin: folders: - /usr/share/n98-magerun2/modules - /usr/local/share/n98-magerun2/modules - /home/foo/.n98-magerun2/modules - /var/www/html/lib/n98-magerun2/modules helpers: composer: N98\Util\Console\Helper\ComposerHelper database: N98\Util\Console\Helper\DatabaseHelper dialog: N98\Util\Console\Helper\DialogHelper parameter: N98\Util\Console\Helper\ParameterHelper table: N98\Util\Console\Helper\TableHelper injection: N98\Util\Console\Helper\InjectionHelper script: folders: - /usr/share/n98-magerun2/scripts - /usr/local/share/n98-magerun2/scripts excluded-folders: - .github - dev - etc - generated ``` -------------------------------- ### Clone Repository and Install Dependencies Source: https://github.com/netz98/n98-magerun2/blob/develop/README.md Clone the n98-magerun2 repository from GitHub and install its dependencies using Composer. ```bash git clone https://github.com/netz98/n98-magerun2.git cd n98-magerun2 composer install ``` -------------------------------- ### Compare Module Versions Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/sys-setup-compare-versions.md Run this command to compare module versions against the saved setup version. Use options to control output and logging. ```bash n98-magerun2.phar sys:setup:compare-versions [--ignore-data] [--log-junit="..."] [--format[="..."]] ``` -------------------------------- ### Start MCP Server with Include/Exclude Filters Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Starts the MCP server, specifying which commands to include and exclude. This allows fine-grained control over exposed tools. ```bash n98-magerun2.phar mcp:server:start --include="sys:cron:* cache:*" --exclude="sys:cron:history" ``` -------------------------------- ### Conventional Commit Examples Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Provides examples of valid Conventional Commit messages, demonstrating different types and scopes. ```markdown feat: add user login functionality ``` ```markdown fix(cache): correct total price calculation ``` ```markdown docs: update README with installation steps ``` -------------------------------- ### Interactive Download Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/project/download.md Run the interactive wizard to guide through download choices. This mode prompts for strategy, edition, and repository. ```bash n98-magerun2.phar download ``` -------------------------------- ### Install Test Dependencies with Composer Source: https://github.com/netz98/n98-magerun2/blob/develop/tests/readme.rst Use this command to install all necessary development tools for running tests, including PHPUnit. Ensure you have composer.phar available. ```sh composer.phar --dev install ``` -------------------------------- ### Install N98-Magerun2-Dist via Composer (Global) Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Install the n98-magerun2-dist package globally using Composer. Ensure ~/.composer/vendor/bin is in your PATH. ```bash composer global require n98/magerun2-dist ``` -------------------------------- ### Install Mage-OS with DDEV Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/local-ddev-setup.md Install Mage-OS, a fork of Magento, into a persistent test environment using the `install-mage-os` custom DDEV command. The instance will be located at `/opt/magento-test-environments/`. ```bash ddev install-mage-os ``` -------------------------------- ### Use Custom Command Groups with mcp:server:start Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/extend-mcp-server-start-command.md Execute the `mcp:server:start` command using your custom command groups for inclusion and exclusion. This demonstrates how to apply the defined groups in your workflow. ```bash n98-magerun2.phar mcp:server:start --include="@safe-default" --exclude="@unsafe" ``` -------------------------------- ### Unattended Magento Installation Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/installer/install.md Perform an unattended installation by providing all required options as arguments. This is ideal for automated deployments. ```bash n98-magerun2.phar install [options] ``` -------------------------------- ### Install N98-Magerun2 System-Wide Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Copy the executable n98-magerun2.phar file to a system-wide binary directory. ```sh sudo cp ./n98-magerun2.phar /usr/local/bin/ ``` -------------------------------- ### Install n98-magerun2 in Build Phase Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/hosting/adobe-commerce-cloud.md Add these lines to the build step definition in your .magento.app.yaml file to download, install, and alias n98-magerun2 during the build phase. ```yaml hooks: # We run build hooks before your application has been packaged. build: | set -e php ./vendor/bin/ece-tools run scenario/build/generate.xml php ./vendor/bin/ece-tools run scenario/build/transfer.xml # ADD THIS LINES BELOW TO YOUR BUILD STEP DEFINITION curl -O https://files.magerun.net/n98-magerun2.phar \ && mv n98-magerun2.phar bin/n98-magerun2 \ && chmod +x bin/n98-magerun2 \ && echo "alias mr2='~/bin/n98-magerun2'" >> ~/.bash_profile ``` -------------------------------- ### Example PHPUnit Command Test Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md A basic example of a command test class extending TestCase. Use the assertDisplayContains method to check command output. ```php assertDisplayContains('your:command', 'Expected output text'); } } ``` -------------------------------- ### Conventional Commit Footer Example Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Example of a Conventional Commit footer, showing how to denote breaking changes and close issues. ```markdown BREAKING CHANGE: changes the API of the cache command Closes #123 ``` -------------------------------- ### Docusaurus Cache Commands Index Example Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Example Markdown file for Docusaurus, listing cache-related commands and linking to their detailed documentation. This helps keep the command reference concise. ```markdown --- title: Cache Commands sidebar_label: Cache --- # Cache Commands Commands for interacting with and managing Magento's various cache systems. ## Commands - [cache:clean](../../system/cache-commands.md) - [cache:disable](../../system/cache-commands.md) - [cache:enable](../../system/cache-commands.md) - [cache:flush](../../system/cache-commands.md) - [cache:list](../../system/cache-commands.md) ``` -------------------------------- ### Custom Dev Console Command Example Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/extend-dev-console-command.md Implement a custom Dev Console command by extending AbstractConsoleCommand and defining its name, description, and execution logic. ```php setName('dev:console:my-custom') ->setDescription('My custom Dev Console command.'); } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln('Hello from my custom Dev Console command!'); return 0; } } ``` -------------------------------- ### Custom Dev Console Make Command Example Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/extend-dev-console-command.md Create a custom 'make' command for generating files, extending AbstractGeneratorCommand and utilizing Laminas Code for class and file generation. ```php setName('dev:console:make:simple-class') ->setDescription('Generates a simple PHP class file using the code generator') ->addArgument(self::CLASSPATH, InputArgument::REQUIRED, 'Class path (e.g. Foo/Bar)'); } protected function catchedExecute(InputInterface $input, OutputInterface $output) { $classFileName = $this->getNormalizedPathByArgument($input->getArgument(self::CLASSPATH)); $classNameToGenerate = $this->getCurrentModuleNamespace() . '\' . $this->getNormalizedClassnameByArgument($input->getArgument(self::CLASSPATH)); $filePathToGenerate = $classFileName . '.php'; /** @var $classGenerator ClassGenerator */ $classGenerator = $this->create(ClassGenerator::class); $classGenerator->setName($classNameToGenerate); $fileGenerator = new FileGenerator(); $fileGenerator->setClass($classGenerator); $directoryWriter = $this->getCurrentModuleDirectoryWriter(); $directoryWriter->writeFile($filePathToGenerate, $fileGenerator->generate()); $output->writeln('Generated ' . $filePathToGenerate . ''); } } ``` -------------------------------- ### Build n98-magerun2 PHAR from Source Source: https://github.com/netz98/n98-magerun2/blob/develop/README.md Build the n98-magerun2 PHAR file after cloning the repository and installing dependencies. ```bash ./build.sh ``` -------------------------------- ### Start MCP Server with Group Include/Exclude Filters Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Starts the MCP server, including commands from the 'read-only' group and excluding commands from the 'unsafe' group. This demonstrates using multiple group filters. ```bash n98-magerun2.phar mcp:server:start --include="@read-only" --exclude="@unsafe" ``` -------------------------------- ### Start MCP Server with Group Include Filter Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Starts the MCP server, including all commands belonging to the 'cron' group. This simplifies exposure of related commands. ```bash n98-magerun2.phar mcp:server:start --include="@cron" ``` -------------------------------- ### Composer.json Static File Mapping Example Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/extend-composer-redeploy-base-packages-command.md Base packages require a static file mapping in their composer.json file. This example shows a typical mapping structure. ```json "extra": { "map": [ [ ".editorconfig", ".editorconfig" ] } ``` -------------------------------- ### Clone Your Fork Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/create-pull-request.md Clone your forked repository to your local machine to start making changes. ```bash git clone https://github.com//n98-magerun2.git cd n98-magerun2 ``` -------------------------------- ### Configure Algolia Search for Local Preview Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Optional: Configure Algolia search by copying the example environment file and setting your API keys. If not configured, the search bar will be hidden during local development. ```bash cp .env.example .env ``` ```bash ALGOLIA_APP_ID=your_app_id ALGOLIA_API_KEY=your_search_only_api_key ``` -------------------------------- ### Basic Custom Command Structure Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/add-custom-commands.md A fundamental example of a custom command extending `AbstractMagentoCommand`, including basic configuration and execution logic. ```php setName('foo') ->setDescription('Foo test command') ; } /** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int|void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->detectMagento($output); if ($this->initMagento()) { var_dump($this->getCommandConfig()); $output->writeln(__DIR__ . ' -> ' . __CLASS__); } } } ``` -------------------------------- ### Configure ddev post-start hook Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/install-in-ddev.md Add this hook to your .ddev/config.yaml to trigger a script after ddev starts. ```yaml hooks: post-start: - exec: bash .ddev/install_magerun.sh ``` -------------------------------- ### Configure Command Groups in config.yaml Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mcp/mcp-server-start.md Example configuration for defining custom command groups in config.yaml, which can then be referenced using the '@' syntax. ```yaml commands: N98\Magento\Command\Mcp\Server\StartCommand: command-groups: - id: cron description: Cron related commands commands: "sys:cron:*" ``` -------------------------------- ### Get Customer Info by Email Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-info.md Use this command to fetch basic customer details. Provide the customer's email address and optionally the website scope. ```shell n98-magerun2.phar customer:info [email] [website] ``` -------------------------------- ### Run Unit Tests Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Command to execute unit tests using PHPUnit, with an example targeting a specific test file. ```bash vendor/bin/phpunit ``` ```bash vendor/bin/phpunit tests/N98/Util/Console/Helper/DatabaseHelperTest.php ``` -------------------------------- ### Get Magento Version Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/add-custom-commands.md Retrieve the current version of the Magento installation. ```php $version = $this->getApplication()->getMagentoVersion(); ``` -------------------------------- ### Example Output of dev:keep-calm Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/development/dev-keep-calm.md Illustrates the typical output format of the dev:keep-calm command, showing which commands are being run or skipped, and a final summary checklist. ```text 1. 🚀 Running command: hyva:config:generate 😊 Skipping command: hyva:config:generate (app/etc/hyva-themes.json exists) 2. 🚀 Running command: setup:upgrade ... (output of each command) Command Execution Summary: 1. ⏭️ hyva:config:generate - Generate Hyvä theme configuration files if they are missing. (app/etc/hyva-themes.json exists) 2. ✅ setup:upgrade - Run setup upgrade and database schema/data updates. Clears also the cache. ... ``` -------------------------------- ### Get Magento Root Folder Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/add-custom-commands.md Retrieve the root directory of the Magento installation. ```php $rootFolder = $this->getApplication()->getMagentoRootFolder(); ``` -------------------------------- ### Clean Magento Cache Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/usage-and-general-commands.md An example of running a common n98-magerun2 command to clean the Magento cache. ```sh php n98-magerun2.phar cache:clean ``` -------------------------------- ### Get Help for a Specific Command Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/usage-and-general-commands.md Use the --help option with a specific command to view its detailed usage information. ```sh php n98-magerun2.phar --help ``` -------------------------------- ### Example Module Command Structure Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/modules/structure.md A basic PHP class extending `AbstractMagentoCommand` to define a custom command within a module. It includes command naming, description, and execution logic. ```php setName('mynamespace:foo') ->setDescription('Test command registered in a module') ; } /** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int|void */ protected function execute(InputInterface $input, OutputInterface $output) { $this->detectMagento($output); if ($this->initMagento()) { // .. do something } } } ``` -------------------------------- ### Get All Tables with Database Helper Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Retrieve a list of all table names from the database using the database helper. ```php $tables = $this->getHelper('database')->getTables(); ``` -------------------------------- ### Install Bash Autocompletion for N98-Magerun2 Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Copy the Bash autocompletion file to the appropriate directory for your system's bash-completion setup. ```sh sudo cp res/autocompletion/bash/n98-magerun2.phar.bash /etc/bash_completion.d/ ``` -------------------------------- ### Verify N98-Magerun2 Installation Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Check if the N98-Magerun2 installation is successful by displaying its version number. ```sh ./n98-magerun2.phar --version ``` -------------------------------- ### Use mydumper for Faster Dumps Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/db/db-dump.md Enable the use of mydumper for potentially faster database dumps by using the `--mydumper` option. This requires mydumper to be installed. ```sh n98-magerun2.phar db:dump --mydumper ``` -------------------------------- ### Usage of design:demo-notice Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/design-demo-notice.md This shows the general usage of the command, including available arguments and options. ```bash n98-magerun2.phar design:demo-notice [options] [] ``` -------------------------------- ### Install MageForge without Post-Install Check Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/mageforge/mageforge-install.md Use this command to skip the post-installation compatibility check after installing MageForge. ```bash n98-magerun2.phar mageforge:install --no-check ``` -------------------------------- ### Create app/etc/env.php Interactively Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/config/config-env-create.md Use this command to initiate the interactive creation of the app/etc/env.php file. The process will prompt you for necessary configuration details such as database credentials and the crypt key. ```bash n98-magerun2.phar config:env:create ``` -------------------------------- ### Ask for Store with Parameter Helper Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Prompt the user to select a store. Requires input and output objects. ```php $this->getHelper('parameter')->askStore($input, $output); ``` -------------------------------- ### Compress Database Dump using gzip Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/db/db-dump.md Use the `--compression="gzip"` option to compress the database dump using the gzip tool. Ensure the gzip CLI tool is installed on your system. ```sh n98-magerun2.phar db:dump --compression="gzip" ``` -------------------------------- ### Enable Demo Notice Globally Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/design-demo-notice.md Use this command to enable the demo store notice for all store views at the default scope. ```bash n98-magerun2.phar design:demo-notice --on --global ``` -------------------------------- ### Install n98-magerun2 via Composer Source: https://github.com/netz98/n98-magerun2/blob/develop/README.md Install the n98-magerun2 distribution package directly into your Magento 2 project using Composer. ```bash composer require n98/magerun2-dist ``` -------------------------------- ### Ask for Website with Parameter Helper Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Prompt the user to select a website. Requires input and output objects. ```php $this->getHelper('parameter')->askWebsite($input, $output); ``` -------------------------------- ### List All Routes Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/routes/route-list.md Execute this command to list all available routes. No additional options are required. ```bash n98-magerun2.phar route:list ``` -------------------------------- ### Install n98-magerun2 script Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/install-in-ddev.md This bash script downloads, verifies, and installs the latest n98-magerun2.phar, replacing any pre-installed version and creating necessary symlinks. ```bash #!/bin/bash if [ ! -f "/usr/local/bin/n98-magerun2.phar" ]; then curl -sS -o n98-magerun2.phar https://files.magerun.net/n98-magerun2.phar curl -sS -o n98-magerun2.phar.sha256 https://files.magerun.net/sha256.php?file=n98-magerun2.phar shasum -a 256 -c n98-magerun2.phar.sha256 rm n98-magerun2.phar.sha256 chmod +x n98-magerun2.phar sudo cp -f n98-magerun2.phar /usr/local/bin/n98-magerun2.phar rm n98-magerun2.phar # remove pre-installed version sudo rm /usr/local/bin/magerun2 sudo ln -s /usr/local/bin/n98-magerun2.phar /usr/local/bin/n98-magerun2 sudo ln -s /usr/local/bin/n98-magerun2.phar /usr/local/bin/mr2 sudo ln -s /usr/local/bin/n98-magerun2.phar /usr/local/bin/magerun2 fi ``` -------------------------------- ### List Configured Store URLs Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/sys-store-config-base-url-list.md Execute this command to display a list of all base URLs configured for stores. ```bash n98-magerun2.phar sys:store:config:base-url:list ``` -------------------------------- ### Install N98-Magerun2-Dist via Composer (Project) Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Install the n98-magerun2-dist package into your project using Composer. This package provides the phar file without dependencies. ```bash composer require n98/magerun2-dist ``` -------------------------------- ### Customer Create Command Syntax Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-create.md This is the general syntax for the customer:create command. It outlines the required parameters and optional fields. ```bash n98-magerun2.phar customer:create [email] [password] [firstname] [lastname] [website] [--format[="..."]] [additionalFields...] ``` -------------------------------- ### Navigate to Docs Directory Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Change your current directory to the 'docs' folder to manage documentation files. ```bash cd docs ``` -------------------------------- ### Show Integration Information Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/integration/integration-show.md Displays all details for a given integration name or ID. This is the basic usage of the command. ```bash n98-magerun2.phar integration:show ``` -------------------------------- ### Install PHP Phar Extension Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/tips/troubleshooting.md On Debian-based systems, use this command to install the PHP phar extension if you encounter a 'PHP Fatal error: Class 'Phar' not found'. ```bash sudo apt-get install php-phar ``` -------------------------------- ### List All Integrations Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/integration/integration-list.md Use this command to list all existing integrations. The output can be formatted in CSV, JSON, YAML, or XML. ```sh n98-magerun2.phar integration:list [--format[=FORMAT]] ``` -------------------------------- ### Example BATS Test Case Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/testing/functional-tests.md An example of a BATS test case that verifies the 'admin:user:list' command. It checks the exit status and the output for expected content. ```bash @test "admin:user:list command lists users" { run $N98_MAGERUN2_BIN admin:user:list [ "$status" -eq 0 ] [[ "$output" == *"admin"* ]] } ``` -------------------------------- ### Show All env.php Settings Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/config/config-env-show.md Displays the entire content of the env.php file in a table format when no specific key is provided. ```shell n98-magerun2.phar config:env:show # whole content ``` -------------------------------- ### Formatted Error Message Example Source: https://github.com/netz98/n98-magerun2/blob/develop/tests/bats/test_helper/bats-support/README.md This is an example of a formatted error message, typically used to indicate differences or failures in test assertions. It includes a header, the specific error, and a footer. ```text -- ERROR: assert_output -- `--partial' and `--regexp' are mutually exclusive -- ``` -------------------------------- ### Create Dummy Tables and Views SQL Source: https://github.com/netz98/n98-magerun2/blob/develop/tests/functional_tests_views.md SQL script to set up test tables and views for database command testing. Ensure your test environment supports these operations. ```sql -- Create dummy tables CREATE TABLE IF NOT EXISTS test_table1 ( id INT AUTO_INCREMENT PRIMARY KEY, data VARCHAR(255) ); CREATE TABLE IF NOT EXISTS test_table2 ( id INT AUTO_INCREMENT PRIMARY KEY, description TEXT ); -- Populate with some data (optional, but good for verifying dumps) INSERT INTO test_table1 (data) VALUES ('Sample data 1'), ('Sample data 2'); INSERT INTO test_table2 (description) VALUES ('Description for T2-1'), ('Description for T2-2'); -- Create dummy views -- Note: Adjust view definitions if 'core_config_data' or other tables don't exist or are empty in your test env. -- A simple view on a known table is sufficient. CREATE OR REPLACE VIEW test_view1 AS SELECT id, data FROM test_table1 WHERE id = 1; CREATE OR REPLACE VIEW test_view2 AS SELECT description FROM test_table2 LIMIT 1; -- Example view for dump tests that might be part of a @stripped group CREATE OR REPLACE VIEW test_view_stripped AS SELECT * FROM test_table1 LIMIT 1; -- Verify creation (optional) -- SHOW FULL TABLES; -- SELECT * FROM test_view1; -- SELECT * FROM test_view2; ``` -------------------------------- ### Install N98-Magerun2 via Composer (Source) Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Install the n98/n98-magerun2 package via Composer. This method is not recommended for daily use due to potential compatibility issues with project and Magento core dependencies. ```bash composer require n98/n98-magerun2 ``` -------------------------------- ### Install Magento CE with DDEV Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/contributing/local-ddev-setup.md Install a specific version of Magento Community Edition into a persistent test environment using the `install-magento-ce` custom DDEV command. The instance will be located at `/opt/magento-test-environments/`. ```bash ddev install-magento-ce ``` -------------------------------- ### List All Store Views Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/sys-store-list.md Executes the sys:store:list command to display all available store views. This is the default usage without any specific formatting options. ```bash n98-magerun2.phar sys:store:list ``` -------------------------------- ### Show Integration Information with Format Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/integration/integration-show.md Outputs integration details in a specified format like JSON, CSV, or XML. Use this to integrate command output with other tools. ```bash n98-magerun2.phar integration:show --format=json ``` -------------------------------- ### Enable Template Hints Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/development/dev-template-hints.md Use the --on option to enable template hints for debugging. ```sh n98-magerun2.phar dev:template-hints --on ``` -------------------------------- ### Force NPM Install for Theme Build Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/development/dev-theme-build-hyva.md Use the `--force-npm-install` option to force a fresh `npm install` before building the theme CSS. This is useful if you want to ensure all dependencies are up to date or if you encounter build issues related to missing or outdated node modules. ```sh n98-magerun2.phar dev:theme:build-hyva --force-npm-install ``` -------------------------------- ### Configurable Git Repositories for Project Download Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/project/download.md Shows how to configure preset git repositories for the download command, allowing for custom URLs and labels. ```yaml commands: N98\Magento\Command\Project\DownloadCommand: git-repositories: - name: magento2 label: "Magento 2 (official core)" url: https://github.com/magento/magento2.git ``` -------------------------------- ### Display Applied Configuration Files Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/magerun/magerun-config-info.md Use this command to view all configuration files that n98-magerun2 is currently using. This is useful for understanding the configuration hierarchy and troubleshooting. ```bash n98-magerun2.phar magerun:config:info ``` -------------------------------- ### Get MySQL Variable Value Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Retrieve the value of a specific MySQL system variable. ```php $waitTimeout = $this->getHelper('database')->getMysqlVariableValue('wait_timeout'); ``` -------------------------------- ### Build Static Documentation Site Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Generate the static HTML, CSS, and JavaScript files for the documentation site. The output will be placed in the 'docs/build/' directory. ```bash npm run build ``` -------------------------------- ### Enable Demo Notice for Specific Store View Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/system/design-demo-notice.md Use this command to enable the demo store notice for a specific store view, identified by its code. ```bash n98-magerun2.phar design:demo-notice --on de ``` -------------------------------- ### Display Database Information Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/db/db-info.md Use this command to quickly print all information about the current configured database in `app/etc/env.php`, including connection strings for JDBC and PDO. Helpful for debugging and environment checks. ```bash n98-magerun2.phar db:info [options] [--] [] ``` -------------------------------- ### Get Bash Completion Directory Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/installation.md Retrieve the compatible directory for bash-completion files using pkg-config. ```sh pkg-config --variable=compatdir bash-completion ``` -------------------------------- ### Get PDO DSN with Database Helper Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Retrieve the Data Source Name (DSN) for the database connection. ```php $dsn = $this->getHelper('database')->dsn(); ``` -------------------------------- ### List Customers Command Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/customer/customer-list.md Lists customers with optional formatting and search parameters. The output is limited to 1000 records by default, but this can be overridden in the configuration. The search parameter filters by first name, last name, and email. ```bash n98-magerun2.phar customer:list [--format[="..."]] [search] ``` -------------------------------- ### Enter Development Container Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/build-docs-on-your-machine.md Use this command to enter the development container if you are using ddev. ```bash ddev ssh ``` -------------------------------- ### Usage example for ddev magerun command Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/install-in-ddev.md Once the custom command is in place, you can use 'ddev magerun' to execute n98-magerun2. ```bash ddev magerun ``` -------------------------------- ### Access n98-magerun2 via SSH Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/hosting/adobe-commerce-cloud.md After a successful deployment, you can use the installed n98-magerun2 tool by typing 'mr2' in an SSH session. ```bash magento-cloud ssh -e master bin/n98-magerun2 ``` -------------------------------- ### Create Integration Command Syntax Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/integration/integration-create.md This is the basic syntax for the integration:create command. Use this to understand the required and optional arguments and options. ```sh n98-magerun2.phar integration:create [options] [--] [ []] ``` -------------------------------- ### Using the Custom Dev Console Command Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/extend-dev-console-command.md Execute your registered custom dev:console command from the n98-magerun2 REPL. ```bash dev:console > dev:console:my-custom ``` ```bash dev:console make:simple-class Foo/Bar ``` -------------------------------- ### Get MySQL Client Connection String Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Obtain a connection string suitable for use with the external MySQL CLI client. ```php $connectionString = $this->getHelper('database')->getMysqlClientToolConnectionString(); ``` -------------------------------- ### Clone n98-magerun2 Repository Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Clone the n98-magerun2 project repository using Git. Navigate into the cloned directory to proceed with setup. ```bash git clone https://github.com/netz98/n98-magerun2.git cd n98-magerun2 ``` -------------------------------- ### Show Specific env.php Setting Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/config/config-env-show.md Retrieves and displays the value for a specific configuration key from the env.php file. ```shell n98-magerun2.phar config:env:show backend.frontName ``` -------------------------------- ### Run DB Query with Database Helper Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/extending/development/helpers.md Execute a raw SQL query against the database using the database helper. Ensure you have obtained a valid connection object. ```php $db = $this->getHelper('database')->getConnection($output); $db->query('DELETE FROM foo'); ``` -------------------------------- ### Configure Test Environment Variable Source: https://github.com/netz98/n98-magerun2/blob/develop/AGENTS.md Set the N98_MAGERUN2_TEST_MAGENTO_ROOT environment variable to point to your Magento 2 installation directory for running tests. ```bash export N98_MAGERUN2_TEST_MAGENTO_ROOT=/path/to/your/magento/installation ``` -------------------------------- ### Create Database Command Source: https://github.com/netz98/n98-magerun2/blob/develop/docs/docs/command-docs/db/db-create.md Use this command to create the database defined in your Magento configuration. Ensure the database user has the necessary privileges. ```bash n98-magerun2.phar db:create [--connection=CONNECTION] ```