n98-magerun2 v7.0.0 released

Published by Christian Münch on

Manchester in the background and v7.0.0 in foreground.

We are happy to announce a new major release (code name Manchester). The new release contains a big refactoring and some new commands. It should improve the compatibility a lot.

Adobe Commerce 2.4.6 / Magento 2.4.6

This release is tested against the latest Adobe Commerce 2.4.6 release which was available as beta version. The stable release of Adobe Commerce and Magento will be arrive tomorrow.

PHP 8.2

We had to upgrade the code base of n98-magerun2 to be compatible with PHP 8.2. It’s still compatible with PHP 7.4, PHP 8.1. Please note that we dropped the support of PHP 7.3.

Mage-OS Nightly Build

The current release is also tested against the nightly build of Mage-OS. So we try to guarantee that every user of n98-magerun2 can work with a compatible build. This helps to find issues in a very early stage.

Magento 1 detection removed

We dropped the detection of Magento 1 in the tool. Over several years the tool printed a message if you try to run the phar inside of a Magento 1 installation. The removed logic simplifies the bootstrap process.

Magento Core Proxy Command

With each release of Magento/Adobe Commerce, it is becoming increasingly difficult to maintain compatibility. In most cases, changed dependencies are the reason for this.

This release of n98-magerun2 brings a significant change to the core of the tool. In all previous versions, we bootstrapped the Magento environment and loaded the internal Command Lists of Magento. Then, we registered all commands of Magento to the n98-magerun2 Symfony Application.

This release introduces a new Proxy Command, which is now used in place of the original command. The command mirrors the signature (options, arguments, and help) of the core command. If you call such a proxy command, then the tool will delegate the call to the bin/magento command of the Magento installation. With this approach, it is no longer necessary to be compatible with all Symfony Components of the Magento Core. We still have enough dependencies to cover, but it helps a lot.

Therefore, we can update the Symfony Console component of n98-magerun2 to Symfony v5 and still call the old Symfony v4 commands of older Magento versions.

We observed a nice side effect: we were able to run the phar test suite against the EOL Magento CE 2.3.7-p4 without any issues. This does not mean that we officially support this outdated Magento version anymore (it is no longer actively tested in Github Actions), but it is good to know that the phar works again with this old version.

If you run the command with -vvv option then the full bin/magento command will be printed out for debugging in the case you run a core command.

The proxy command is intelligent enough to figure out which options are part of n98-magerun2 (like the –root-dir option) and which are part of the mirrored command.

We know that this change is really big. We changed >100 files in the n98-magerun2 code base. If you see any issues, please create a Github issue.

Improved Stability

n98-magerun2 was broken if you try to run it in a corrupt Magento environment. With this catch Magento exceptions during initialization of the core commands. If the core commands are not available we catch the exceptions and provide the n98-magerun2 commands only.

In such a case the tool should print a error message so that you can see what’s going on.

The self-update command was optimized to run without any Magento initialization. In previous versions you had to call the self-update command outside of a broken Magento environment.

New Indexer/MView Commands

There are two new commands available to show the merged configuration data of indexers and mviews.

Simply run:

n98-magerun2.phar config:data:indexer
n98-magerun2.phar config:data:mview

Both command provide a --format and a --tree option.

tree output example

Nix-OS Support

There are two nix-os packages available to install the latest n98-magerun versions (Thanks to Pol Dellaiera).

https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=magerun

Changelog

  • Add: Magento 2.4.6
  • Add: Magento 2.4.5-p2
  • Add: #1041: New command config:data:indexer (by Christian Münch)
  • Add: #1042: New command config:data:mview (by Christian Münch)
  • Add: #1126: Add CONTRIBUTING.md and CODE_OF_CONDUCT.md (by Christian Münch)
  • Imp: New internal proxy command to call Magento Core Commands (by Christian Münch)
  • Imp: Disabled Magento and config initialization if self-update command runs (by Christian Münch)
  • Imp: Update 3rd party dependencies (Symfony, psysh, captainhook, php-cs-fixer, phpunit, twig)
  • Del: Support for PHP 7.3
  • Del: Remove internal test setup for Composer 1 based Magento installations
  • Fix: Initialize Magento only once which should prevent several issues with DB and config. (by Christian Münch)
  • Fix: Remove “please select” entry in search:engine:list command (by Christian Münch)

5 Comments

Georg · March 20, 2023 at 15:31

Hey there,
is there a way to connect on magerun2 for db:dump with a connection string?
For example just like this:
`
n98-magerun2.phar db:dump –connection=”server=mysql;uid=root;pwd=magerun;database=magerun”
`
I cant find a format in the descriptions, or do i need the env.php?

Regards, Georg

    Christian Münch · March 30, 2023 at 19:57

    No. It’s using the values of app/etc/env.php.
    It’s possible to dump only the command with `–only-command` option and to modify the options then.

Dasitha · April 22, 2023 at 19:21

Hi Christian,

Is it possible to implement a way to read-only access available user to connect to DB via db:console command? If this is possible it would help to prevent accidental writes on PROD DB when working with multiple DB sessions (local, PROD).

Thanks

Kind regards,
Dasitha

    Christian Münch · June 15, 2023 at 19:53

    That’s maybe possible. Can you create a GitHub Feature Request?

The Openstream #54 – März/April 2023 - Openstream · March 11, 2024 at 10:03

[…] n98-magerun2 v7.0.0 […]

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.