Laravelstream· Jan 28, 2025· 1:11:16
We'll be right back.
Thank you.
hello world technical difficulty to start 2025 but that's all right hello world we are live welcome to the january 2025 edition of the laravel worldwide meetup it's hard to
believe it's 2025 already. I was saying to someone that feels like a year that should be in the future somewhere, but here we are. It's a new year, new beginnings, but what we know we're going to be bringing you this year are more great talks and more great people from the Laravel community. Margaret, how are you doing? How's 2025 been for you so far? I've been pretty great. It's crazy to realize that we've been doing this for a year now. So insane. But yeah, I've been doing awesome.
Thanks, Dan. What about you? Same. Yeah. It's moving along. It's we're almost we're on the doorstep of February already. Hard to believe I'll say it again. But here we go. And yeah, like I was reflecting, too, it's been a year now. And our first talk last year was was Caleb Porzio, Mr. Larraville Livewire and kind of fitting that that our talk today is Livewire focused as well. So looking forward to it. We're going to have Josh out here in a moment. But before we do that, we have got a little bit of housekeeping to touch on.
So without further ado, what do we got here, Margaret? Awesome. Thank you, Dan. So, yeah, welcome to anyone that's new to the meetup and welcome back to anyone who's been a part of this meetup. We're going to run through some resources here. So if you haven't heard about Laravel News, it's a great resource ran by the great Eric Barnes. They have a weekly email newsletter and you can check them out at LaravelNews.com. They also have a podcast ran by the wonderful Jake Bennett and Michael Drinda, where they discuss all the latest Laravel releases in the last week. They have tutorials and happenings in the Laravel community.
Next is Laravel Podcast hosted by the wonderful Matt Stauffer. So this season he's joined regularly by Taylor Atwell and so if you want to learn more you can check them out at Laravelpodcast.com. Lara Jobs is another wonderful resource so if you're looking to hire, you're looking to post a job and really for all your Laravel job needs you can check them out at Larajobs.com. What we wanted to do this month is feature a couple of companies that are looking to hire Laravel and PHP developers this month. So you can check out Prompt Therapy Solutions,
Not, Wild, Alaskan Company, and The Number Company. We'll include their link in their job postings in the description below. So if you're a Laravel developer looking for work, be sure to check them out. Up next is Laracast. So big thank you to Jeffrey Way for running this awesome resource for anyone looking to build their Laravel skills. And it's really a platform to learn with others in the Laravel community. So check them out if you want to learn some Laravel. All right, for some upcoming events that's happening later this year,
Laracon EU is just right around the corner. So tickets, unfortunately, are sold out, but there is a waiting list. So if you'd like to get on that, make sure to check them out at laracon.eu. It's going to be happening in Amsterdam, Netherlands. And that's February 3rd and 4th. Up next is Laracon India. This is going to be held in Ahmedabad, India. So that's going to be March 8th and 9th, 2025. If you'd like to learn some more, you can check them out at laracon.in.
Another wonderful online meetup resource is the GTA PHP user group. So they are a wonderful group of developers, especially in PHP that talk monthly and you can check them out at meetup.com. It's in the greater Toronto area. And again, thank you to our host for their support and relaunching this meetup. They have a great team of developers. So if you want, if you have a Laravel problem, they'd be happy to help you out.
make sure to hit them up at vehicle.com or go at vehicle.com. And also thank you to our sponsor, JetBrains, for being able to give away a couple of one-year subscriptions to any JetBrains IDE. So you can sign up by scanning that QR code and the winners will receive an email from our team. So watch out for that email. And I'll pass it off to Dan to introduce our speaker for this month. Thank you, Margaret. Our speaker this month, like I said, is going to be talking about something
Laravel Live Revelated. It's Josh Seary. You've probably encountered Josh, either met him in person or you've encountered some of his awesome videos on the Laravel YouTube channel or across the social medias. Josh works in developer relations at Laravel. And today he's going to share a really kind of interesting tool that exists in the Laravel ecosystem called MingleJS. So without further ado, let's bring Josh in here. Josh, how are you doing today? Hey, everyone. I'm doing pretty good. How are you all doing?
Excellent. Excellent. We were, we chatted last week, I was taken back a little bit. That wasn't quite the same background I was expecting from all your awesome videos on YouTube and such, but you're in the process of setting up a new office there, but things are looking good. How's that coming along? Yeah. Process of setting up, we just recently moved. So process of setting up a new office, new studio. The good thing is I have a lot of big plans for this space and a lot
of flexibility and new stuff. So I won't get to show all the new stuff in the office today, but that'll come shortly. So I have a lot of big plans, a lot of big goals. Yeah. One of those things, I'm sure that's a lot of work, but also exciting to do every time you get to build a new office and build out all those things, right? Yeah. It's exciting, but it's also annoying too, because then you start to realize all the things that you're like, oh, this would be nice to have. And then you got to like, Amazon is great,
but you still got to wait, you know, a day or two to like get the thing. And then it's like setting it up and you realize, Oh, that's too short. Or that won't work. It's not good enough. I think. So it's a, it's a, it's a process. You always, I always think I have everything I need. And then, you know, three days, four days later, I don't have it. All right, cool. So I think, I think we're good to go. If you are Josh, if you want to go ahead and share your screen and then Margaret and I will
just kind of step backstage and we'll hear all about MingleJS. So without further ado, we'll hand things off to you and we'll chat with you in a few minutes. Good. Awesome. Hey everyone. I'm probably not gonna be following the chat too much, but if you like have any questions as I go, thanks so much for everyone for being here. I'm super excited to share this kind of tool that I discovered probably over a year ago
that was created by someone by the name of Patricio. I think he's actually in the chat as well, Patricio on code on Twitter slash slash GitHub as well. But this talk is entitled, Let Your Live Wire App Mingle. So as I go, make sure if you have any questions about either what I'm talking about or just things related to this, if I can't answer them, I know Patricio who is out here will be able to answer them as well.
So I always love to share things that I find, things that are especially in the Laravel ecosystem, the Laravel community, and things that I just find interesting in general. I do a lot of tinkering in my spare time. I do a lot of building, even if it's just little things like, how would I use this PDF export Laravel Spotsy package? How would I use this when I actually need that tool? And so hopefully the goal of this talk
is to give you another tool in your proverbial tool belt to be able to say, hey, now that I have, now that I know this exists, maybe that one time I actually need something like this, then it will come into handy. So this talk is entitled, Let Your Livewire App Mingle. So Livewire is great. Even on the Livewire homepage, Taylor Otwell said that IMO,
That's in my opinion. For those who don't know, Livewire takes Blade to the next level. It's basically what Blade should be by default. So I love Livewire. I came from the JavaScript ecosystem back a couple of years ago when I started, three or so years ago when I started building in Laravel. I came from JavaScript. I knew React. I knew a little bit of Vue. I knew Svelte. I liked those things. I knew what the front end should look like and like what I liked about the front end.
But when I moved into Laravel, Livewire clicked with me because I could call these things from the server without having to write a controller. And that blew my mind. And so I love Livewire. It's something that I am really passionate about. And most of my demo applications are just anything that I build within, whether that be like side projects or just demo projects or even larger applications, usually I start and reach for Livewire.
Like, for example, you could have this public function save right here. And I don't have to create a whole new controller to do this, to create a new post and then redirect to slash posts. I can just call it on the front end. And if you're here, you probably already know what Livewire is. But Livewire is great in the sense that it makes things like this easy. But ecosystem is everything.
We're part of the Laravel ecosystem. And one of the things that really sold me on coming to Laravel, I always tell my story about how I decided to start building in Laravel. And a lot of it came from a guy named Chris Sev, who just recently joined the Laravel team.
He put out this Notion document about two and a half years ago, three years ago, where they basically said, hey, these are the reasons why we're moving our project from Next.js to Laravel. And a lot of it came down to ecosystem. There's so much that not only Laravel as a first party gives you for free, but so many third party systems.
And while LiveWare is great, it's not the same tenure as something like React or Vue or even Svelte, for example. I mean, we have things like Flux now, which help. We have things like Filament, which is built in LiveWire. And a lot of those things make LiveWire better, and I'm super grateful for them. But there's a reason why Vue and React are so widely used.
whether you love Vue, love React, or you hate Vue or hate React, or you just haven't even tried them, and maybe you're just still using PHP with Laravel and Blade, and you're not even touching Livewire, regardless of where you're coming from today, whether you're a Livewire expert and you know Livewire more than me, or you're a Vue or a React expert with Inertia.
there's no denying that Vue and React have their place in the developer ecosystem. They have tools that have been, have stood the test of time. They have people using them each and every single day. And the more you use a tool, the better it gets because other people are using it too. That's why Laravel, for example, consistently gets better. So the better the ecosystem, the better opportunities you have to find that one package or that one library
or that one thing that you might need. So if you wanted to build an application and you knew that you needed either a specific library that was a viewer react specific library, and it would be a little bit more difficult to just build that in plain vanilla JavaScript, or you know that your client's needs need this specific interactivity that is more single page application. You don't want to have to write all of that
in something like Alpine. What are your options when it comes to writing within Vue or React in Laravel? Most people kind of already know this, but if you don't, you have Inertia, which is fantastic. It's great. I actually started learning Laravel with Inertia and with Vue, and I'm actually going to be on a panel tomorrow talking about Vue at the Vue school conference, online conference. But Inertia is great. Inertia 2.0 just released, and there's so many fantastic
basic options and themes and features, just easy ways to make a React or Vue or Svelte application work fantastic in Laravel without having to write an API to connect the two. And then you also have like Next.js or Vite or Remix, and you can pair it with the Laravel backend where you say, okay, I'm just going to write all my front end in Next.js or Vite or Remix, and then I'm just going to
just pair it with laravel when i need it maybe i need cues or maybe i need a a background job or maybe i need i don't know a mailing system and you can do all of that it works great for that there's a bunch of people building in this maybe you're one of them so you have those options but what happens when you need something more what happens if you want to dive in to a livewire app that has
react or view mingled together and that's where mingle js comes in because a lot of times if you're if you're like me most of the times you're you're reaching for those other options when you know that you're going to need a react component or a view component or a specific library maybe something like shad cn or maybe something like uh tremor which is a graphing and charting library
specific for React. And while there's so many things that are slowly moving to like vanilla JavaScript, even like React or Framer Motion that is now just motion.js, a lot of the times they are moving to something like vanilla JavaScript, but it's still tricky to implement. And it might be better developer experience if you're working in something like React. And that
is where mingle js comes in because if you're like me you're someone who wants to build and move quickly so i'm building like a new project a new um a new application something just test the waters and i need to get something up and running usually that's why i reach for livewire but now if i need that specific package do i rewrite my whole application or do i mingle it together
so this is mingle js i'm gonna jump out and kind of show the the home page right here this is mingle js and this is like i said written by uh or created by patricio um i believe he's still in chat as well um so again this is not something that i created um i'm just a fan of it and something that's i actually learned about probably a year or so ago when he when he first first released it
but there's some there's some great options this there's some great opportunities within mingle.js and hopefully i get to show a little bit about why what makes it so special but make sure you check out um the website that's minglejs.unitedbycode.com but again uh this is uh if i'm not mistaken it's not uh production ready yet i i've i've used it in some of my production applications but it's not
not necessarily production ready it's still a very early release just as a disclaimer but there's a reason why mingle.js works the way it does so of course we could go through all this if we really wanted to but why don't we actually jump into some code and i can show you specifically itself too so Let me open up my code editor real quick. All right.
And we're going to go to this application, and we're going to open it up. All right. So this is a standard Laravel application. Right. Everyone's familiar with this. You have, you know, you have your routes.
And let's just say that I have a route that I want a Livewire component on. Maybe we're doing something where we need to send something to a cube job. So maybe I want to say, like, this is going to be route view. And we're just going to say, like, send message. And then we can, like, send that message.
Okay, great. Well, I'm using the Laravel VSCode application, so now I can just go ahead and create this quick blade. I'm just going to use the guest layout here, and I just want to go ahead and just create a new button. And in this button, I want to just, or I just want to create a new LiveWire component. So this is all relatively familiar if you've been working within LiveWire.
but we're just going to go ahead and make a new Livewire component. And I want to call this, I don't know, send message. There you go. And then I can go ahead and put this in here, right? We can go Livewire, send message. Perfect. Now I'm going to go ahead and open this up in our browser.
So this is all fairly standard in the sense that we're running the Livewire component now. And if we go to send message, we have nothing yet. Let's see. Did I send message? We have the view of send message. And we probably don't have anything in the actual send message Livewire component.
So we'll go ahead and say, hi there, Laravel Worldwide. Perfect. And there we go. Hi there, Laravel Worldwide. So this is great. This works perfect. But let's go ahead and wire this up. What if we needed something like React to use in this LiveWire application?
because, of course, yeah, we could do something like a button, and we could send this message, and then we could have in our send message LiveWire component, we could say we want this to send message, and we'll just go ahead and die and dump this. So now we have all of our LiveWire functionality hooked up, of course, right? We're not touching anything else besides LiveWire,
send message redinded. This is great if you're using just plain library. Like I said, a lot of the times, if you're using an application, maybe it's too tedious to write something that is more client-side stuff that it would be just great to ship a specific component library or something that is in React. For example, there's things like MotionJS that would be, while they do have a JS
specific a library for it it means you're hooking it up to maybe alpine within the library application and so there's a react version that just makes it a little bit cleaner or there's something like tremor where you have these dashboard components and charts that to be honest if i was to build this from scratch it would take a little bit of time especially if i was to build this within something like alpine jf of course there's there's some great options already out there for
something like Alpine JS. But again, React has and Vue has that seniority in the same way that Laravel has its seniority as an ecosystem as a whole. So what happens if we take this Livewire application, again, super basic, we're not going to get into the styling aspect of it as well, just the functionality. What happens if we wanted to actually connect this to a React component?
And the good thing is Mingle.js makes that happen. I've already installed Mingle.js. There's a whole section on the website for installation and setting it up. But this is what this would look like. If I wanted to create a new React component within my Laravel Livewire application, it's as simple as saying PHP Artisan make. And then we'll actually, as a Mingle,
I think it's makeMingle, sorry. MakeMingle. And then we want to do a React component. And I'm just going to call this, maybe we'll say sendMessage. We'll call this, let's do this sendReactMessage. All right. And now I have this sendReactMessage.php that was created.
And you look at this, send react message.php that was created. And you look at this, and this looks fairly similar because this looks like a LiveWire class. We have a class that extends a component, and that component is still a LiveWire component, but then it implements this has mingles directive. So we're going to dive into the code specifically just so we know what's going on, and then we're going to see what that actually looks like implementing that in the React component.
itself what it does is we just have a component that returns a specific javascript implementation and the cool thing is we can set into that component any specific data so if i wanted to say our specific message would be um hello laravel worldwide all of a sudden we're not just it's similar to inertia where we're pushing props to our component but we're doing it all within a
a Livewire class. So now in our send react message.jsx, we can accept anything that we're sending from that Livewire class. So not only do we have the ability to grab specific messages, like in our mingle data, but then we could also display those messages because we're already accepting them. So if I wanted to say like this is the message, or maybe I'll just go like this.
This is the message. And then there we go. And the good thing about this is that I'm not, I am not kind of like pushing this React component and then I have to call like an API and then I'm pushing that into the DOM element for React. All of that's handled for us within MingleJS. So if I wanted to hook this up to this send message.blade.php
or actually I'll probably do in the, I'll probably go in, I'll probably go for this in the send message blade file that we have. And now I can call Livewire and then we're going to send react message. And this is something that I think we have to do currently.
I could be wrong on that, but then we're going to go send react message to bring this in for beat as well. So what this is doing is bringing that Livewire component. You'll notice we're not saying like this is a PHP component or anything like that. This is a Livewire component that I'm displaying on the page as well as my original Livewire send message component. So I go back
All of a sudden, now we have this separate. Let me go ahead and even just clear out this original LiveWire component. Now we have a React component. This is something that is built specifically in React. I can do any React stuff in this component because it is React first and foremost.
You can see here that we have our send react message with a console log that was in our original JavaScript send react message as well. We are console logging that specific message, but then we're also displaying it too. And that's the neat thing about Mingle JS is, yes, you can use LiveWire just as you're normally used to using LiveWire.
but you can also use a React component and mingle it in together. So let's do some crazy stuff. Let's say we wanted to do the same exact thing of where we wanted to start a job. And so what if I wanted to, in a button, I wanted to say, you know, we're going to wire call, and then I want to call,
let's go ahead and call send server message. Okay, this isn't hooked up anywhere, right? We don't have the send server message. But because we're passing this wire prop into our React component, now in our send react message livewire php class, all of a sudden, I can just create a new public
function send server message and i can go ahead and do whatever i want here maybe i could create a new job or i wanted to just go ahead and die dump and this is a server message now neat thing about this i don't know why i left it this is what i get for letting copilot write my
code, but I left the message as double it. So we'll say a send server message right here. All right. So if we go back, send server message. Now, that's pretty crazy, right? We wrote React code, but we're talking to our Livewire application, and we are sending a server message without having to write an API to do anything else.
This is hitting our server. It's hitting our Livewire class. And it's actually running this die and dump function where we're talking to the server. Okay, that's pretty crazy. That's great. Again, this is the reason why I started using Livewire is because I wasn't smart enough or I didn't know enough things about, I didn't like writing controllers.
It wasn't something that I was used to writing React or Vue or Svelte because I wasn't used to like that model V controller imperative. But this means I could write a React component and then just call a public function, a method, just like I would within Livewire. So great. This is working. This is working good. But again, we passed in some data. Okay, that's great.
we are calling specific methods on the server that's pretty much that's 90 percent of what most people might need within a react component because now we can write our react we can return all this we can do all this client side but at the same the first moment that i need to touch the server we can just use this wire.call and whatever method is available in that livewire method that livewire class is now available in the server now that's all great but what
if we want to go one step further? For example, what happens if I want to, maybe I have a Livewire component that I want to actually interact with a React component? Okay, I've already kind of set this up, but we have this, I have this, let me go into my web routes here. I have this,
I have this listen.php component. Actually, it looks like I didn't set it up in this application. So we'll set it up together. So I have, what I want to do is I want to connect to a, we'll go ahead and we'll probably keep this and we have a listen.php class. But I want to do is in
a, let's go ahead and create a new LiveWire component. So in a, let's see, PHP Artisan, we're going to make a new LiveWire component. And let's go ahead and say we want to interact with React. So we'll just go ahead and say this is declare React. There we go.
So in our declare react, we'll go ahead and create a new web page for this. We'll go ahead and say that this is, we'll say route view and this is a declare and so we can call the declare react, we'll just call the declare view. okay I'm going to go ahead and create this so declare create the missing view and we're going
to say that this is the x uh the guest layout and I'm just going to say that this is uh x or actually I'll go ahead and say that this is the livewire declare react and that's what I called it right yeah we have declare react oops
declare.blade.php perfect so in our web routes we have the declare route we're going to declare dot blade.php and what we want to do in our livewire declare to react uh blade.php is we just want a simple let's say we're working in a very complex dashboard and most of our dashboard
is in Livewire. But for some specific purpose, we need a Livewire or a React component that's, I don't know, maybe this is a loading component, or maybe this is a specific client-side component that we might need. This is our actual charting dash, but we need it so that when a user clicks a button, we want to do something within that React component. In Livewire, you have the ability
to send events. You might be thinking, okay, this could be complicated because I want to send an event to a React component that is rendered by a LiveWire class. I don't know how I would do that. Well, actually, it's fairly simple because if I was going to say WireClick equals declare in our declare React LiveWire view, you might think, yeah, what you would do is declare. And then we might do
something like this dispatch, and I want to say, maybe like declare. Okay, because if I was writing a new LiveWire component, I would then listen. On declare, I want to do something, whether that's on the server side, or there's ways to do it within like AlpineJS or something within the
client side as well. And the good thing within MingleJS is it makes that incredibly easy too. Because if I was to go ahead and create a new MingleJS component, I'll go ahead and say make Mingle. And I'm going to say, listen, listen here. There we go. Listen here. And we'll go ahead. Oops.
it's probably because i accidentally added this here so go ahead and do that we'll call it a react and we'll say listen here oops i messed it up because i didn't actually do like the react piece there we go okay we'll create a react component listen here all right there we go so now in our listen
listen here library component this is our mingle js component that we're pushing to our react component and again all of this can be done within view as well i'm just using react for this particular application but now i can say a public function maybe i'll just say we'll go ahead and do something because now you're like oh yes on declare i want to do something i'll bring
this in. So on declare, this is standard livewire attributes. I want to do something. In this case, maybe I'll die and dump and we say we did something. Okay. That's all great. And that probably would work as you might expect because if now in my declare react livewire component,
we have this button in our declare blade we're already pushing it in so this should work as you expect but i guess one of the thing that we might want to also do because we are pushing this within livewire is we also want to dispatch to a specific component so i'm just going to say to and then i want to say the listen here class this is just uh helpful within livewire if you
wanted to dispatch an event to a specific class that you know is going to be listening for it. And in our use case, if we're pushing this to a specific React component because we knew we wanted to do something with it, that would be what we would want to reach for. Okay, so if I want to go ahead and go to declare, we don't have a React component on this page at all. If I was to declare it, nothing's going to happen, right? We're dispatching to a specific class that is not
actually initiate on this page. So why don't we go ahead and do that. In our declare.blade.php, we'll go ahead and say, I think Patricio on code mentioned that I probably have something missing for my specific setup. I tried to get it right, but I might have something specific that I am not doing properly. But now I want to go and in my live wire, I want to say,
listen here. Again, that's that component that we did for React. And now I'm refreshing. I'm going to declare, and we have that dying dump. Okay, that's working great because we're not actually using any React, right? This is just technically two live wire components talking from one to another. We did something. We declared it. We did something. We're talking to the server
in another component. Again, two live wire components talking together, not super flashy, not super exciting in a lot of ways. But can we do something even better? Well, we can. So in our listen here, JavaScript, this is our React component. Maybe we want to do something on the
client because that's what we're all here for. So what we could do is wire.on declare, and then we're just going to do something in the console instead. Again, this is now the server talking to our server livewire component and then pushing into the client. Does this work? Let's see. Because now we have declare and I probably missed something up. Let's see.
So, wire on declare and am I actually calling the, okay, we have livewire listen here. I think that's proper. Let's see. Livewire listen here. We have our declare react. Oh, that's why. We're not actually declaring react.
we need our JavaScript of listen here. So that is going to be the listen here.js. There we go. Now declare. And now all of a sudden we have... I probably am still missing something here. So live demos, everyone. This is what happens. So we're going to take a look at the documentation
because that is exactly what you do. I probably missed the spelling one. So in events, we have the ability to read it from the JavaScript as well, where we can say props.wire.on. I think I was doing that, but maybe I missed something up. Let's see. We have listen here.jx. We have our props already destructured. So we have wire on declare. Did I, I might not have called it declare. That's probably why.
naming is important um if on declare do something uh-huh it's probably because we don't want it to talk to the server anymore because we're only wanting to re uh interact on the client so now if i click declare we still aren't doing anything okay well i probably am missing something there but the cool thing is when we talk to or when we use
events within Livewire, you can also use those events within your React Mingle component as well. So for example, I can now talk from one component to another, from a Livewire component to a React component, even though there's still two PHP Livewire classes, not only can we do something on the server, but we can do something on the client as well. And the docs are going to
be like the setting stone for that, where not only can we emit things from backend to backend, but we can also dispatch things from the client as well. And last but not least, I wanted to talk about one new thing that just kind of shipped there. Actually, our DocsGrep, I was talking to Patricia before, about how you, because most of the time within your React component, you want
all the niceties of Livewire, like those methods that we can talk to from client to server, and you want the ability to be able to write React. That's usually if you're reaching for something like MingleJS, you just want the ability to write React, but without having to redo your whole application or somehow work your way into transpiling an inertia application, but only for a certain set of pages, because what if you only wanted a component on one page?
again the reasons why are fairly standard but you also want those niceties as well so we're going to go back into my code i already set this up where we have the this mingle demo view what we're doing here is bringing in this to-do manager i have a list of to-dos in my
backend. And I want to then push those to do's into the front. And this is, this works just like how you would expect if you're pushing any props from your backend to your front end. You have to do's and now you have to do get, I only want to grab the ID and the title, and then I want to push those to an array to the front end. Well, now that we have our to do
manager react component. We'll just say, hi there, Laravel Worldwide. But now we have exactly what we would expect. We're already initiating the to do's because there are prop from the front end, props.mingled data.todos, and now we can just map over them. Okay. This works great, but let's go ahead and what happens if we have actual server expenses?
because a lot of times if you're sending this kind of data to your front end, even if it's a LiveWire app, if it's a Nurtia app, most of the times you need something that is going to be expensive. It might take a couple of seconds. And here in my to-do manager, I've actually said in our mount function, I want to just sleep for two seconds. Well, I already have this set up,
but Mingo.js has the ability to do lazy components, just like you would expect within a LiveWire application and even within Inertia.js now that there are kind of like these placeholder components that you can wait and defer those loading until you actually have that information in. And it's as simple as putting a placeholder, just like you would in a LiveWire class,
and then at the top we just bring in this lazy attribute so now if i was to go to this mingle demo page right here we're expecting this to wait for two seconds because it's sleeping we have this little spinner and then we get the information that we need all of those to do's that we're pushing to the server that we're looping through all of a sudden we have the ability to
have this lazy component. You can see how this could be very useful if you had a full server rendered application, maybe one Livewire component needed to do something, but now you needed a React component on your page. Now, all of a sudden, you don't have to just have that component be blank or have that component wait for all of the other components to load. Now you can just have that one single component be lazy. There's so much other stuff that Mingle.js makes easy, but most
of most of these times I'm using something like a specific react component, a specific react library, or just something that I know would be easier in react than trying to find a way to do it in vanilla JavaScript. And that's where I think mingle.js actually shines, letting your livewire application still be a livewire application, still be able to have the ability to write specific,
functions or being able to pass data or even methods that now I can call from my React component or review component, but now I don't have to choose one or the other. I don't have to choose the DX nicety of Livewire and also miss out on things like React, or I don't have to choose the awesome abilities of inertia and React, but then I have to make sure I have to have a controller
for everything and a route for everything to make sure that all that's working properly and again there's a time and place for all of that but if you're wanting to move fast mingle.js works great for that because now we can take our live wire application maybe our existing live application maybe you have a live application like i do that's in production that's thousands upon thousands of lines of code but i haven't refactored it because i just need that one specific piece to be a react
component and that's where mingle.js comes in because now you can take your livewire component and you can actually mingle it and that's where i think mingle.js works fantastic uh so thanks so much for um for letting me share it with you again patricio has been in the in the chat putting it together uh but uh he's the real mastermind and the brains behind all of this as well but i'm
excited that I get to show a little bit as well. So I think right now we'll move into probably taking some, some questions. All right. Thank you. I got a little sound effect that I hope comes through here. Big shout out. I mean, giving, giving a presentation of any kind in front of an audience is a daunting task, but a live coding presentation is, is even more daunting and you
crushed it man i know you ran into maybe a little bit of an issue there with but uh you know minor and all things being said so fantastic job with the with the live demo josh that was great thank you thank you cool yeah um i think uh first off the i think one of the first comments you made kind of uh resonated with me and it was i had a similar thought to uh leading into this talk and i was uh looking over some documentation and stuff and it's it's the kind of it's the kind
a tool you're not going to need all the time. But when, when you when you may need it, when you're in that situation, knowing that it's there is really nice, right? And it may be the kind of thing that you could reach for and be really helpful, right? So I think that that is definitely true, right? It's like, you kind of think in some ways, oh, it's, as you know, as you kind of understand the philosophy of Livewire is going to help you kind of stay in PHP, stay away from getting getting heavy into JavaScript, right? So why would you want a tool that allows you to use JavaScript in Livewire, you wouldn't be using
live were. But I think the one one of the things I've encountered in working in software for a long time now is like, there are lots of reasons why the code is in a certain spot. And you may be needing a certain thing at a certain time. Who cares what those are the fact you need them is you need them, right. So I think yeah, totally having knowing that tool is on the shelf and knowing that you can reach for it when you need it is huge. Exactly. And that's really what it comes down to right knowing the tools on the shelf, because I think that's, you know, when
you're building an application, most of the time you reach for familiarity. That's a lot of times why now I reach for Livewire a lot because I just know. I know if I look at an application, this is how I would build this in Livewire. But now I also know that I'm not limited to a lot of times if I want to do, you know, connect to the server, but not write a whole bunch of client-side JavaScript, while Alpine.js is great. A lot of times there's things that have already been solved for me. And And if I could just pull in a React component for that one thing, then it makes great.
100%. Yeah. A couple of things, potentially, I was kind of brainstorming, like, you know, where could I, you know, find myself reaching for this, right? And I think that even the documentation speaks to it. One could be, it could be sort of a, I think of a transitionary tool almost, right? And I say that in, like, you could maybe potentially have a viewer React-heavy application and want to move to LiveWire long-term or vice versa.
And I can see a tool like this being really handy, being able to bring it in and start introducing things, you know, kind of piecemeal as you go along, as opposed to having to make a full transition. Another one that struck me, again, you know, a bit of a contrived scenario, but you could find yourself in it is like maybe you're in an organization that has multiple applications, different tech stacks across applications. And there could be components that are used in another application that are mostly do what you need them to do. being able to pull those in and not having to rebuild them, so to speak, in JavaScript might
be really helpful as well, right? Yeah, exactly. Because I think what helps there is, and even like there's a lot of people who are moving to Livewire applications, but they still have like a Vue SBA, or maybe they're using just Vue inline with Blade for specific interactions. And now you're, okay, maybe you're not fully even moving into Livewire, but you still want to have that the niceties of live wire maybe you have you know you're just incrementally moving to live wire now
you don't have to give up those view interactions that you have as well if you didn't want to fully move into inertia yeah that totally um yeah go ahead margaret no i just had a comment about that too because i was wondering how to make components feel native when you're kind of going from like react view and using live wire app so i feel like i kind of answered a little bit of that so thank you um and then also just kind of like sorry i didn't mean to cut you off josh we're to say something there? Oh, no, no. I was just going to say that being native is the more
important part because a lot of times you'd reach for developer experience when you're looking for a new tool rather than just the functionality of what that tool provides. So I think the ability to say, okay, I have my full blade component, but now I just need that one thing just like you would within Livewire. Now you can just do it within React too. Yeah, sure. And it was really cool seeing in the comments, like there's, there's somebody, I think Carlos mentioned that he's actually learning live wire for the first time this week. And so learning all the different
components, different things that you could do. I guess, just general question for you. What was your kind of like onboarding, like ramp up process, integrating MingleJS into the ecosystem that's kind of already built in there? Do you mind speaking a little bit more on that? Yeah, yeah. The process of, of, of, in like installing MingleJS is actually like fairly straightforward because even for my fairly heavy livewire applications, because one,
you can use Vue or React within LingoJS and it doesn't, you don't have to choose one or the other. You can use both Vue or React, maybe even both within a single application. But two, it's incremental in the same way that livewire is incremental. So a lot of times I don't do this as well as I should, but usually most people recommend, hey, if you're building an application, and start with blade. And when you need a form or you need something like that, then you can just pop in a LiveWire component.
Usually I'm the opposite and I start with like a full page LiveWire component. So it's not what I should be doing. But the good thing within MingleJS is once you have it installed, then I can just pop in a MingleJS or React LiveWire component wherever I might need it. And it doesn't have to affect the rest of my application. It just lives in its own little containerized state. Cool. Thank you.
Let's have a few questions in the chat here. So I think you've already touched on it already, but we'll throw it up here. So Manjeet asks, does Mingle, I think, work with both React and Vue kind of at the same time in a single app? Yep, it does. It does. You do have to have both React and Vue installed. and like if you wanted to use like hot module lodging like put them in uh view and react within like your v config and everything but yes you could have in one page uh have a view react and
livewire component all together and they would be talking to the same you know database have different livewire classes that's pushed to those components you can't have one livewire class that pushes to a view or react view at the same time but you can definitely have them working in the in the same application together for sure. Cool, cool. Yeah, again, it's probably an odd scenario you'd find yourself using both React and Vue at the same time. Never know. Never know, right? The tool's there if you need it.
On a similar vein, we have a question here. I wanted to use an NPM package in my mingle component. Do I define that in my package JSON at the root level and import it as usual? Yep, yep. So I can probably actually share my screen again because I forgot to talk about this. I have motion.js installed here. So if I was to go into my motion.php,
I'm not doing anything other than having in my package.json, I have React or I have motion install. So I just npm install motion, but now in my motion.jsx, I can just import that at the top. and it works as you would expect. So this is nothing, it's not talking to the server at all, but I'm just pushing this into a React component that's containerized in my Laravel application.
All of those niceties work great. So yeah, you can definitely use this, any JavaScript component, any React component view library that you're wanting to bring in, you would just use that as normal in your .jsx or .vue file. yeah that that sounds great uh question here i mean this is very generic but what about
performance i don't know what about performance what about performance uh i i i need to i am not the best at talking about uh um how great it is i so patricio on goat and also there's a page on the the, it's called, I believe it's called YMingleJS, or maybe it's just what is MingleJS or something
like that. But it's talking a little bit about how it actually works behind the scenes and the documentation. And I think the performance is exactly what you would expect from putting a React component. If you were to push, what it's doing is essentially taking your React DOM or your view dom and placing it on the stage and then just using um using ajax requests to push in or pull information so i think the performance is exactly what you would expect from if you're using a view
spa um or even just like a view component on your page and you're kind of rendering that to a specific root element so i don't think the the performance is any much different than if you're using those react or view in those situations i think with the for usually where performance comes down to within applications like this is are you talking to the server when you should be or are you keeping things on the client and usually that's tough within livewire because you think
oh if i want to counter i want to make sure i have a add count uh public method but you're talking to the server there so performance is going to take a hit but within react or view it kind of makes it easier because you're used to doing all that on the client anyways yeah okay so josh would you say this is a good resource for like maybe anyone else who's maybe hesitant and might like over complicated library apps like going to look at this documentation would be able to solve a lot because we just put that in the link description below as well and then people can check that out
there too yep yep i i think the the documentation does a great job and looking at some of like the the demos and demo source code to see exactly what um that is showing me i think it shows a a lot and there's specific pages on how to use it within like something like filament or something like that as well. But yeah, I think it's, if you think about it as being containerized within your application, it kind of helps, at least in my mind, it helps me think, okay, I'm not necessarily
bringing React and it's leaking into my application, but in this one specific frame, I have a React component. Okay, cool. Awesome. Yeah. I mean, any chance to kind of see how you work and how you like think about things I think is super great for the audience or even just for myself. And yeah, even in parts of your talk, just kind of seeing how you think through things. It's very enlightening. So thank you. Awesome. Thank you. I think, and again, too, like the, so many different possibilities,
the more I think about it of like different ways you can do things with the tool. Right. And some of them are probably better ideas than others, but again, you know, knowing that, that it's there and those are possible is, is, is pretty cool. So the one thing that, or I guess the question I had was, do you have, in your using MingleJS and actually integrating it to some applications, do you have any tips or advice for people in terms of implementation? And I say that thinking along the lines of,
let's say I had this component maybe that I owned already that I was pulling in that wraps some NPM package. and maybe it's, you know, by nature has to hit the server with some data, right? If I pulled that application or that component in rather and buried in that component that existed, it was making, you know, XHR calls to the server, right? That wouldn't be ideal if I'm trying to bring that into a Livewire app, right? I'd almost want to structure things, I would think, to have like those inner components just emit events up
and then, you know, I can pull that in and whatever the thing is pulling that in can decide what to do with those events, right? So that was one thing that crossed my mind. but anything in that realm, Josh, you've run into of like, hey, keep this in mind. Maybe you might have an easier time with things. Yeah, I think that's a great point. I think what has helped me in the, so I have two kind of production applications, SaaS products that I've implemented Mingle.js and because I needed,
one was a chart library that I needed to kind of display to my users. And then second was mostly because I wanted to use React Motion, which is now just MotionJS.
And so I think the things that I would kind of reach for MingleJS for or kind of like keep in mind is usually what I was thinking through of when I actually create a MingleJS component is when I would otherwise be reaching for like an at script tag on my livewire component. or maybe like using a bunch of Alpine JS for some very like client side stuff.
A lot of the times that is when I would, okay, let me just push this to React. So that way I know, okay, everything is on the client and I'm writing code or maybe like bringing in libraries that is meant for that. One thing to keep in mind through that all is you still have the nature of, these are still separate components. So just like you would have two LiveWire components,
And if you haven't worked within Livewire extensively for some of this need, it can be tricky when you think, OK, I have this one component that needs to talk to two components and one's lower down and one's higher up in the architecture of things. I always opt for personally using that dispatch to method because most of the time I know the specific component that I need to do something with when something happens.
But then Livewire, the good thing within Mingle.js is the server side part is all Livewire. So all of the elements that you would expect within Livewire, maybe I need to talk to all child components or all parent components. Then that's where I would kind of opt for that. But I think one thing to keep in mind within Mingle.js, kind of similar to maybe like an inertia app where you have most of the time you're thinking,
if it can be done in reactor view or spelt it can be done in inertia inertia is just the glue together where mingle js is kind of like the glue between live wire and now you just have a reactor view front end and so uh yes it's live wire can be a little bit tricky or sticky once you get i have you know thousands of nested components and so i would think to always keep in mind of
when does a component actually need to be a component versus when can this be multiple components pushed into one or maybe that's just a blade a blade file and then I have a specific component as well so components can be can be tricky within within Livewire but I think within MingoJS one of the things one of the things to always keep in mind is when do I actually need
this to be specific client side. And then that helps me at least realize, okay, now this is where I could use that instead of live wire. Yeah. And I do think too, probably one of those things that there's no substitute for just trying it out and playing around with different patterns and seeing what you do, right? Absolutely. Again, another kind of general question here from the chat,
but how does Mingle.js affect the scalability of Laravel applications? Are there any limitations or considerations for high traffic applications? And there probably always are, but is there anything specific that comes to mind for Mingle.js specifically for you, Josh? Yeah, I don't think so, other than any options that you would think within a traditional
livewire application. So, you know, again, a mingle.js component is a React view pushed into a livewire island, if you will. And so I think the thing to keep in mind when it comes to scalability of variable applications or considerations for high traffic is what actually needs to go from server to client versus what can just stay on the client. I think that's
actually what mingle.js in a lot of ways might be more helpful to add to a liveware application where you can kind of bottleneck yourself within a liveware application of maybe doing too much stuff on the server and not enough stuff on the client. And while yes, you can do all that within vanilla JavaScript in a livewire component, I think that's what mingle.js might be. If you're
used to if you're used to doing it client-side stuff or you have an app that has high interact client-side interactivity i think mingle.js can almost help with limitations or considerations for high traffic applications because now you're instead of having to have all your users hit the server to get uh you know to get a progress bar um well maybe we're maybe you're pushing the
progress bar and then just incrementally updating it and pinging and pulling the server within mingle.js as well and so i think i think there's uh i think there's fantastic options to make the scalability aspect even easier with the mingle.js because you have that more distinct separation i think between server and client side yeah i guess like used used responsibly it allows you to uh when needed push push more things to the to the user's browser
let the browser do more work and then leave it off the server, right? I guess in a sense. Yeah. Where like within a liveware application, if, you know, if, if I didn't render slash echo out, you know, everything for that, maybe I'm like for a to do's, maybe if I didn't render the users to do, I wasn't pushing that out. It's not going to actually be pushed to the, to that page. But with a mingle now I have to actually think, okay.
now I want to send all the information at once and then kind of maybe this would be a great opportunity before like a table component, for example, where now I'm doing all that heavy filtering and rendering and even maybe searching on the client side if it's not too long of a list. Yeah. Cool. All right. Any other questions from you, Margaret?
No, I guess also just thanks Josh for being able to, I don't know, lower the barrier or just get people more excited about using Mogle.js and then also understanding like how supported everyone in the community is. Like Patricia was here too, answering questions in the chat. Just goes to show how close knit everything is and how well connected the community is. So yeah, thank you so much. Yeah. And I actually, sorry to piggyback on that, Patricia, I saw you in the chat as well. So yeah, thank you for joining us. Thank you for
Thank you for MingleJS. I was also thinking too, you know, the one thing you mentioned Josh earlier was that it's MingleJS is not at 1.0 yet, right? So I'm sure there's lots of work going into it, has gone into it. So I'm sure Patricio would love some assistance from the community, even just, you know, pulling the package down, trying it out, reporting bugs, contributing fixes, that sort of thing. So I'm sure if there's anything else you can add in the chat there, Patricio, but I'm sure the community would love to help you out if people are interested in this tool.
Yeah, hopefully it doesn't get too bombarded with everything now. But yeah, definitely. I think it's been beneficial for me to see what Petrugio has been kind of putting out. And just like I said, that lazy component isn't even something that's documented yet, but I think he pushed that out last week. And I was pretty excited to look into it. Very cool. All right. Well, thank you again for joining us, Josh, and kicking off our 2025 year here at the Laravel Worldwide Meetup. Before we let you go here, was there anything else for you that you wanted to share?
No, yeah, I don't think so. Other than I'm going to be talking at Laracon India as well in March, in March 8th and 9th in Al-Adabhad. Hopefully I said that right. But yeah, super excited. My first time to India. So for those who are here, super excited to be there with everyone who might be going to Laracon India. but yeah be on the lookout if you're not able to go to laraicon eu be on the lookout for what's
happening in this next week at laraicon eu because there's a lot of awesome announcements taylor has already kind of posted that the release date for laravel cloud is going to be announced at laraicon eu so so be on the lookout for that very cool yeah there were actually some other questions in the in the chat about what's coming in laravel version 12 and laravel cloud which understand that people are excited about. So stay tuned. I guess the best advice, check out a later next week. And probably some of,
some or all of those answers or questions will be answered. It will be live streamed. Awesome. Cool. All right, Josh. Well, thanks again. We're just going to let you go backstage and then Margaret and I just have a couple of housekeeping items to, to wrap things up here for this month. So thanks again. Thanks so much, Josh. All right. And there we go, Margaret. So just like I said, before we, we head out a couple of things we want to touch on before, for next month. Yeah, for sure. Thanks so much, Dan. So again, big thanks, Josh, for our next meetup. You can join us on February
25th, 2025 at 12 p.m. We have another core Laravel member joining us, Joe Dixon. So I saw some questions in the chat about Laravel Cloud. If you'd like to tune into our next meetup, there'll be a lot of conversation about that. So please join us then. And if you haven't joined our Jet Brains giveaway rules, you can please scan this QR code to have the form to fill your information, to be eligible to win one of our prizes. So just put this on here if anyone wants some time to read the rules.
Just leave that QR card up for a moment. Again, if you haven't followed us on X yet, you can follow our official channel, Laravel WW Meetup, and you can stay up to date with all the upcoming events and never miss a single one. And again, you can check us out on our official website, meetup.laravelle.com to sign up for email reminders about what we got going on over the next month. So you can do so there. And then again, thanks for watching us on YouTube. Make sure to hit that subscribe button
and hit that bell for any notifications. And this is where you can find all of our other meetups from last year. We did 12 last year and we're trying to do one a month. So please join us on the Laravel YouTube channel. There it is. And with that, that concludes our January 2025 edition of the Laravel Worldwide Meetup. thanks everybody for tuning in thanks once again josh for joining us and taking us on a dive into
mingle js uh anything for you margaret before we sign off uh more so if anyone else wants to contact us on x about any future talks or speakers they'd like to hear from we'd love to hear from you and thanks again for supporting this meetup and watching us and giving us comments and feedback um love hearing it all so thank you so much for everybody absolutely thank you everybody uh have a great day and we'll see everyone at the end of february bye now
Thank you.