Skip to content

Blog

Magewire 3 - Beta Release

Yes, it’s been a while

The months have flown by. On the surface the repo may have seemed quiet, but nothing could be further from the truth.

Behind the scenes, I’ve been working in a separate branch on a hefty list of additions that I absolutely wanted to include in the upcoming beta release.

Critical Security Vulnerability

The biggest strength of Magewire, and one of the main reasons I took on this challenge, is the incredible community already behind Livewire. Livewire has already proven itself as one of the two biggest game changers in the Laravel community.

This means Magewire is not just another new brew of technology in the Magento ecosystem, it’s already a proven solution similar to e.g. AlpineJS.

A good example is security: on July 17th, a critical security issue was fixed in the Livewire repository, and within just 10 minutes, the same fix was applied to Magewire thanks to the way it has been built (ported).

So What's Next?

Feature building has stopped for now. It’s time to focus on improving testing across the board, ensuring everything remains backwards compatible, and writing documentation on how to migrate.

In the meantime, I’m trying to establish a small team to speed things up. But I’ve found that asking for help and getting valuable input is really a struggle—which I totally understand.

Open source in our money-driven community is incredibly difficult, with most people either waiting until something gets released, or creating a clone of what Magewire already is and ending up in the same rabbit hole.

It’s somewhat discouraging, but I suppose that’s the reality :D

So What's New?

I’d like to take you along for a look at what’s been happening, and honestly, these additions are features I’m incredibly excited about.

Fragments

Fragments are a way to convert HTML into what we call a fragment, both inside your template files and even within PHP files. At its core, it’s nothing more than wrapping a piece of HTML so you can give it a name.

The real benefit, however, lies in what you can do with it afterwards. For example, you can treat a fragment directly as a CSP block whenever it involves a <script></script>. And thanks to modifiers, you can centrally manage your fragments without touching a single template.

Fragments were initially intended as a better solution to make scripts CSP-compliant. However, they eventually grew into much more, where they are no longer only needed for CSP or for wrapping <script> elements.

<?php $script = $magewireFragment->make()->script()->start() ?>
<script>
    ...
</script>
<?php $script->end() ?>

Please refer to the documentation for more details.

Template Directives

As you might know from Laravel, Magewire now also supports the use of @ directives inside your Magewire component templates.

Simply put: if you want to display something inside your component only to a logged-in user, you can just wrap it with @auth and @endauth.

The nice part is that this system is built in such a way that you can extend it with your own prefixes.

For example, you could create a @{agencyNameGoesHere}CustomerGroup(1) directive, which ensures content is only shown when the customer is logged in and belongs to customer group 1. This directive would then belong to the agencyNameGoesHere group (area to be specific).

And don’t worry: thanks to the built pre-compiler, everything is precompiled into actual PHP in advance, so nothing happens on the fly.

<div>
    @guest
        <!-- Will only be shown to guests. -->
        <span>Hi guest</span>
    @endguest
</div>

Please refer to the documentation for more details.

Flakes

I really wanted to create a “good” system that lets you easily add re-usable components inside your Magewire components using nothing more than simple HTML syntax. No complicated stuff, no need for additional ViewModels or other workarounds, just like in the following example.

class Dialog extends Component
{
    public string $title = '';

    public function mount(string $fooBar, AbstractBlock $block)
    {
        //
    }
}

Where your template simply looks like this:

<?php $title = 'Hello World'; ?>

<magewire:dialog name="my-component"
                 prop:title="$title"
                 mount:block="$block"
                 mount:foo-bar="baz"
/>

As you can see, you can easily inject public properties, pass mount method arguments, and use template variables as an attribute value.

Please refer to the documentation for more details.

Stream Directive

The Streaming feature has been made compatible and now works within Magewire.

Thanks to the Portman tool we built, it only took about 15 minutes to get it running.

Fortunately, this feature isn’t too complicated, but it does provide you with some cool new options.

Please refer to the documentation for more details.

Rate Limiting

Livewire does not officially support this, but for many reasons I felt it was needed, so I went ahead and built it.

Rate limiting can now be applied in multiple ways. One option is via the frontend using wire:mage:throttle, where most of the handling happens on the client side. This is not bulletproof, though, since a smart user could easily work around it.

That’s why server-side rate limiting has also been added. Based on system configuration, you can now limit the number of subsequent requests within a specific time window.

Cool thing, by default, its cache driven, but you can build your own adapter if you'd like.

Observer Events

It’s not always easy to learn a new framework, I know that. That’s why, wherever possible, we should provide an approach that already feels familiar to you as a Magento developer.

For every hook you can tap into, an observer event is automatically dispatched. This means you don’t have to create a separate Feature for just a small tweak. Instead, you can simply add an event in your events.xml and use the provided Data Transfer Object (DTO) to pass data along to the hook.

Please refer to the documentation for more details.

Backend Compatibility

Yes, Magewire is coming to the backend. All you need to do is require the new module magewirephp/magewire-admin.

I’m currently wrapping up the final details, and then nothing will hold us back from using this powerhouse of a framework in the backend as well.

Magewire 3 - Hello World

Here We Go!

A promise is a promise. I said Magewire V3 would be released a week after the docs went live, and I'm a man who sticks to his word—even if V3 isn't quite where I'd like it to be yet.

From this point forward, we're going to build this airplane while it's getting ready to take off. Luckily, we're still taxiing on the runway, and as long as that beta tag stays on, we'll keep it grounded until it's ready to fly.

The Journey Is What Matters Most

They say it all the time—the journey itself is more important than the destination, and that's no different with Magewire. I've learned an incredible amount as a professional, but also as a person, during this development process. For me, it's been such a beautiful experience to work on something where I could completely let loose on how I wanted the architecture to be.

Through all the years working with Magento 1 and Magento 2, I've always had an extreme interest in architecture and kept challenging myself to improve, try new things, and sometimes go a bit outside the lines of old-school Magento standards. Not everyone always appreciates that, but I figure—if I don't try it and make mistakes, how are we ever going to make Magento attractive to the new generation of developers who really do think differently?

The road has been pretty long, and fortunately, the endpoint isn't in sight yet. Even though many people ask me why I invest so much free time in something that doesn't pay back in a community like ours. I can't say anything other than—this is completely true. The investment is ridiculous, and sometimes I ask myself that same question: what am I doing all this for?

For me, the answer is simple: it makes me incredibly happy. Working on my own thing, not constantly having to worry about what someone thinks of it, and just being able to pour all my knowledge into an ultimate project that I couldn't imagine working without in my daily work anymore.

Now for the Serious Stuff

V3—a lot of the same, plus some innovations that came about partly through necessary things like CSP and other things I've had on my wishlist for a long time but could never really make happen in Magewire V1.

The architecture is solid now, but not everything that's standard in V1 is in V3 yet. There's still plenty that needs to be ported over, but I expect this will go much faster now that all the tools are available. So over the coming months, that's roughly the plan for the beta—to work (hopefully together) toward a version that at least contains everything V1 has.

What's New?

Good question. There are many new features like Fragments, which let you mark sections in your PHTML and tweak them using modifiers. Fragments came about because of CSP—I wanted a tool I could wrap around a script block and then optionally modify based on different variables, like adding a nonce attribute or creating a hash of the content and passing it to Magento's CSP collection. I've expanded this concept to offer other fragments in the future. You could think of feature flags, for example where you can show part of your PHTML only based on a specific version of another package.

There's also a new @ compiler that allows you to use so-called @-directives in your PHTML that automatically get converted to valid PHP during compilation. This creates cleaner, more readable PHTML, but also means less actual PHP code in the PHTML files. There's much less need for all kinds of View Models and Helpers to get things done. I have some really exciting ideas in the pipeline for this feature that I hope to add soon. The groundwork is already laid.

Of course, the completely new documentation shouldn't be forgotten either. I'm glad I set this up because I can now write about things much more specifically compared to the previous approach where everything was buried on a single page in the Magewire repository itself. The domain name might still change to make it easier to find, but the first steps have been taken.

There's so much innovation that I could write endlessly about it, but I think it's smarter for you to take a look at the documentation to get a good picture of what might be relevant for you.

Finally

I'll try to write a blog post every month about Magewire's progress, but I won't make a LinkedIn post about it every time. So definitely keep an eye on this blog page if you're interested in more reading material about this project!

And if you feel the urge to contribute, whether through code or financially, I invite you to get in touch!

Magewire 3 - Docs Publication

Kicking Off a New Chapter for Magewire

First, I’m excited to share that starting today, all future updates about Magewire will be posted right here in the blog section of the documentation.

This shift is all about keeping things simple and centralized. No more jumping between websites to find the latest news or resources—everything you need will now live alongside the docs.

The Wait Is (Kind of) Over!

For those who’ve been patiently waiting: the long silence is finally breaking—at least in terms of documentation.

I’ve spent months putting together the foundation, and while there’s still some work to be done, I’ve decided to release the docs ahead of the actual beta launch.

My goal is to give you a head start—to inspire, to motivate, and to let you explore what's coming in Magewire V3.

The beta code itself is planned for release by June 1st. I just need a few more evening sessions to get it over the finish line.

A Work in Progress (Literally)

Let me be upfront: the documentation is still very much a work in progress.

You’ll see a few WIP... tags sprinkled throughout. These are simply placeholders and reminders for myself—sections that still need attention.

Why This Release Matters

The main goal right now is to help developers get started with V3 as early as possible. By putting the documentation out there, I’m hoping to lay the groundwork for the community to join in and help shape its future.

That said, this is still a passion project—one I mostly work on during evenings and weekends—so progress might not always be rapid. Thanks in advance for your patience and understanding.

What’s Next?

In about a week, I’ll push the V3 beta under a new beta tag in the Magewire GitHub repository (which you probably already know your way around).

From there, things become a little less predictable. The pace of development will depend on a lot of factors, including time, feedback, and community involvement.

Thanks for being part of this journey. Let’s make something awesome together.