Skip to content

V1: Feature: Support Magewire in the backend#139

Open
michielgerritsen wants to merge 1 commit intomagewirephp:1.xfrom
michielgerritsen:feature/support-magewire-in-the-backend
Open

V1: Feature: Support Magewire in the backend#139
michielgerritsen wants to merge 1 commit intomagewirephp:1.xfrom
michielgerritsen:feature/support-magewire-in-the-backend

Conversation

@michielgerritsen
Copy link
Copy Markdown

Last week during the pre-Meet Magento NL Hackathon, I hacked together a proof of concept on getting Magewire to work in the backend of Magento. This PR is the result of that. Next to that, this PR and repository are also required:

The RequireJS adjustments are made as the backend also needs RequireJS support, but the module has a dependency on customer data. It is not required to make it work in the backend, though. Next to that, the form key in the backend is being retrieved differently than in the frontend.

The solution lies mainly in moving configuration from etc/frontend/di.xml to etc/di.xml, and from etc/frontend/events.xml to etc/events.xml. Also, a controller is created in the adminhtml folder, but that extends upon the frontend controller without any changes.

A big question that popped up during the hackathon was what about security? Magewire relies on the form key, which by accident makes it a little bit secure, but the controller does not have any extra security built in. Also, another thing that should be thought about is ACLs.

I have the code for the backend in a separate repository. It is worth considering whether this is the right approach or whether it should be merged into the main repository.

@jissereitsma
Copy link
Copy Markdown
Contributor

Awesome stuff @michielgerritsen . You mentioned the backend code lives in another repo. Do you mean an acl.xml file and backend controller? Because it is just that, it would be quite easy to add to this PR, right? I would say the controller simply needs to be a regular admin controller with ACL resource defined, which then correlates to an ACL resource to the acl.xml file? Or did you had something else in mind?

@michielgerritsen
Copy link
Copy Markdown
Author

@jissereitsma The backend code lives in this repository:
https://github.com/michielgerritsen/magewire-backend

It holds a few things:

  • Files to work properly with RequireJS in the backend. It is comparable to the code in the magewire-requirejs repo, with some backend specific changes.
  • It sets a different base URL in the Magewire ViewModel.
  • It adds a different controller that lives in the adminhtml folder. This only extends from the frontend controller and does not add any logic.

So it's not super much, but a bit more than a simple acl.xml file.

@jissereitsma
Copy link
Copy Markdown
Contributor

I'm currently working on a module in the Magento backend, using Magewire. To load things properly via AJAX, the Livewire controller in the backend module really really needs to be extending upon the admin action, not implementing the interfaces: Those interfaces are meant for the frontend only (as of yet). I'll update things on my side and hope to add a PR to your PR soon.

@wpoortman wpoortman changed the title Feature: Support Magewire in the backend V1: Feature: Support Magewire in the backend Jun 2, 2025
@wpoortman wpoortman changed the base branch from main to 1.x June 2, 2025 19:45
@rbouma
Copy link
Copy Markdown

rbouma commented Aug 14, 2025

For those still on v1 of Magewire who need backend support, we’ve created a fork of @michielgerritsen with some changes and an auto patcher, so you don’t have to worry about patches. Check it out here:
https://github.com/disrex-group/magewire-backend

Credits to @jissereitsma and @michielgerritsen for the original backend patch module.

We’re eagerly waiting for v3 to come out 🙂 Thanks @wpoortman for creating the port of Livewire to Magento, such an awesome addition!

@wpoortman
Copy link
Copy Markdown
Collaborator

He @rbouma, thanks for mentioning that here and awesome you use it also in the backend. I think most credits should just go to @michielgerritsen, he did a great job!

@wpoortman wpoortman added the V1 label Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants