Closed kolaente closed 6 months ago
https://github.com/netz98/n98-magerun2/wiki/Interactive-Console-%28REPL%29#code-generator :-)
Okay I did not know that was a thing :upside_down_face: I guess this Feature request then extends to a) making the code generation commands available as a sub command of magerun (without calling the REPL first) and then adding a new command to create data patches.
..or first add the data patch command and decide later whether to make it available outside of the REPL :)
@cmuench Is there a specific reason to have this commands only in the REPL and not directly-callable?
@amenk the dev:console
is inspired by the tool "Installer" by Jacques Bodin-Hullin.
That's how it is designed. It's not designed for scripting.
So.... historic.
It's possible to add new commands to the REPL as, well.
Commands are registered here: https://github.com/netz98/n98-magerun2/blob/develop/config.yaml#L445
I have not tried to call them in a different contect. Maybe it could be possible to add a kind of proxy command here.
Something like dev:console:call <command> ....
n98-magerun2.phar dev:console "$a = 1; call cache:flush; ls;"
seems already possible anyways...
I would also recommend to focus on adding new generators instead of doing such general changes like adding the Laravel artisan mode :-)
@amenk Could be that I already worked on that topic (I am getting old...), but I guess it's unstable.
seems already possible anyways...
This seems to work with a bash function:
$ m() { n98-magerun2 dev:console "call $1;exit"; }
$ m cache:flush
Magento 2.4.2 Community initialized ✔
At the prompt, type help for some help.
To exit the shell, type ^D.
Psy Shell v0.9.12 (PHP 7.4.23 — cli) by Justin Hileman
New version is available (current: v0.9.12, latest: v0.10.8)
--> call cache:flush
.....
That pretty much gets me the "laravel feeling".
So yeah, I'll put up a PR to add a new data patch generator I guess.
@kolaente Feel free to extend the dev:console.
We saw that https://plugins.jetbrains.com/plugin/8024-magento-phpstorm has such a function and will probably not extend that further here in Magerun2, issue can eventually be closed :-)
We saw that https://plugins.jetbrains.com/plugin/8024-magento-phpstorm has such a function and will probably not extend that further here in Magerun2, issue can eventually be closed :-)
The dev console can be triggered from outside. So it's possible to use the feature for scripting, too. That's IMHO not possible with the PhpStorm Plugin. So there is a place for both.
The dev:console
is awesome :-) I am more talking about such code generation features, those I feel to be more natural in PhpStorm - at least for us :-)
The
dev:console
is awesome :-) I am more talking about such code generation features, those I feel to be more natural in PhpStorm - at least for us :-)
That's ok for me if you use PhpStorm. ;-)
I close this ticket. We should add more specific issues to enhance the dev:console. Feel free to create new issue here.
Feature description
I would love to have an
n98-magerun2 make:...
command, like there exists for Laravel (php artisan make:controller
for example).For example, running something like
n98-magerun2 make:data-patch <module> <name>
would create an empty class<name>
in<module>/Setup/Patch/Data
that implements\Magento\Framework\Setup\Patch\DataPatchInterface
and has the base methods of the interface already created. This could be extended to tests, models, repositories, etc.Problem and motivation
I found myself creating a few data patches lately and manually creating the classes feels like there should be a better way.
Is this something you're interested in working on
If I get time to work on it, yes :slightly_smiling_face: @amenk