Anonymous broadcasts, sorted elements, and Moonshine

Download MP3
Announcer:

This is the Laravel News Podcast, your one stop podcast to find out about Laravel related news, tutorials, packages, and more. Here are your hosts, Jake Bennett and Michael Dyrynda.

Jake:

Hello, everyone. Welcome to episode 214 of the Laravel News podcast. Today is May 7th, and with me as always is my good friend and co host, Mr Michael Dyrynda. How's it going, dude?

Michael:

Hello. Feeling relieved at the moment. I think it's the best way to describe my situation. We just we just published all of the Laracon AU details for 2024. So venue, location,

Jake:

very nice.

Michael:

All of the stuff that I have been talking about in the abstract for weeks now, I suppose, almost probably even months at this point.

Jake:

Yep. So it's, that's exciting. I actually just had, Kevin McKee. You know you know Kevin McKee? Yeah.

Jake:

I know. Yeah. Reached out to me. He said he said, I I sent in a talk, you know, talk proposal to Michael. He said, put in a good word for me.

Jake:

I said, will do. Will do, my friend. So

Michael:

Consider the good word received, Kevin.

Jake:

The good word is received, Kevin. You saw you heard it live on air here at the Laravel News Podcast. It's done. It's done. Well, hey, folks.

Jake:

Should we get into it? We've got some releases today. Actually, just one release, and then we've got a lot of packages to talk about. No tutorials this week. No big deal.

Jake:

Let's jump into Laravel 11.5, shall we? So this week, Laravel team released 11.5, and, of course, this was April 24th, what I'm talking about this week. Laravel team released 11.5 with anonymous event broadcasting, blade performance improvements, and generated URLs with query parameters and more. Let's talk first about anonymous event broadcasting. So Joe Dixon contributed to this, anonymous broadcast in Laravel.

Jake:

This is for real time applications that use Laravel Echo. So if you don't know what Laravel Echo is, Laravel Echo is a really easy way for you to subscribe to WebSocket events that are broadcast from your Laravel back end and then can be received and consumed in the front end. So sometimes you want to broadcast an ad hoc event. Right? This is one where you don't need to hook it into anywhere else in your application.

Jake:

You just wanna notify the front end of something. And so this, you don't wanna go to the trouble of creating a brand new event and then, you know, having to register all that stuff. You just wanna fire off the message. So with that, you can use anonymous broadcasts using the broadcast facade. So it's as simple as doing broadcast, dodot, or double colon, on, and then my channel, send.

Jake:

That's it. You can dispatch to multiple channels at the same time, and then you can broadcast, the anonymous event on a private or a presence channel as well. So the API is really, really simple. It's just like it was said, broadcast on, the channel name, send. And then you could say broadcast private or broadcast presence instead of saying just on, to specify that it's a private or a presence channel.

Jake:

So there's documentation around this already in the Laravel 11 docs. So you can find that at laravel.com/docs/11.x, cause that's what we're talking about, and then broadcasting anonymous events. So cool stuff there. Thank you, Joe Dixon. Really nice.

Jake:

Blade performance improvements. So Taylor threw a tweet out there, and he was like, hey, you know, sometimes I get really obsessed with performance, and I would like to see if blade component rendering performance could be supercharged. So here's the task. Rendering 1,000 anonymous components takes about 14 milliseconds on his MacBook Pro. Can we cut this in half?

Jake:

Dig in. Help me figure it out. Send a PR and cement your legend status. And in fact, a couple people did. Right?

Jake:

So we had Christopher Pitt that jumped in and then Lonnie Cappel and Shnick. And so these two requests were accepted and emerged as part of a Laravel 11.5, which collectively improved Blade not by not by, like, you know, it didn't cut it in half, but it did cut it down by 20%. So there's a supercharged blade PR out there and then a blade component loop speed improvement by those 2 folks. I love how the community just rallies around these silly it's not silly. I I mean, it's great.

Jake:

Right? I mean, we're we're all on the same page. Not silly. It's awesome. But I love that people see this tweet and then immediately go to work.

Jake:

And so really, really cool. Love that. Lastly, we've got Steve Baumann contributing the ability to generate URLs with query parameters via the new query method. So, there is a URL helper that you can get just doing URL, you know, and then parens, and then arrow query, and then you add in products, which is the after the slash, right? So you're gonna do yourwebsite.com/andthenproducts.

Jake:

And then in the second set of, values there, the second argument, you're gonna pass in an associative array of the different query params that you wanna be added on to the end. So for example, you might have a associative array of sort with a value of name, and so you would just pass that in. That associative array is the second one, a second argument to this URL query method, and it's going to create httpcolon/localhost/products, and then the magic here, query sort equals name. Now the funny thing is I would have thought that this was possible beforehand. And, you know, it's just one of those things.

Jake:

It's like I I would've I would've instinctively been like, oh, of course, this exists already. But apparently, it does not. And so, thanks for contributing that one. Nice catch on that one, Steve Bauman.

Michael:

Pre previously, we've had to, like, reach into use there's the build query query build is is like an underlying HTTP build query. I think it's a PHP function where you'd like have to take this on yourself. So it's nice to have again, that that first party quality of life improvement in the framework.

Jake:

I guess I'm wondering, like, I think I've previously used maybe, like, the route helper for something like this. If I had a named route, that was a get, and then you can pass in the query params as a second argument, but maybe this is just on the URL helper. I don't know. I I say that, like, that's how it is. I've I feel like I've done that before, though.

Jake:

Maybe not. Maybe that never existed. I don't know.

Michael:

Laravel on the route, I'm pretty sure will just anything that you take on extra will append as a query query parameter. That's not,

Jake:

you

Michael:

know, a name parameter, but this is, you know, explicit thing to do, you know, using query as a as a specific thing.

Jake:

Method on it. Yeah. Yeah. So that one's cool. If, if that's something you've needed to do, now you can.

Jake:

It's it's available through that URL helper. Okay. I said that was the last thing. Actually, it wasn't the last thing. Milwaddev contributed a default namespace for make trait and make interface, which will create these classes in the following paths if if they exist.

Jake:

So if you want to, make an interface, it will create it in the app slash contracts, and or app slash interfaces location. We'll create these classes in the following paths if they exist. Got it. So if you have a app slash contracts directory or an app slash interfaces directory, and you say, php artisan make interface, it will drop it in either of those two folders so they if they exist. And then same thing, if you make trait and a app/concerns directory exists or an app slash traits directory exists, it'll drop those into those locations.

Jake:

So, there you go. Nice. Nice little, paper cut sort of thing that, if you didn't if you had that and it wasn't dropping them in there, now it will. There. Very cool.

Jake:

Alright. Well, folks, that is 11 dot 5. Nothing too insane, but a couple good things, on the list there. Alright, mister Drinda. Over to you, my friend.

Michael:

Righty o. Christophe Rumpel has started a new video series on the Laravel Organization YouTube channel that is all about Laravel's first party tools, and it will cover everything from the commercial offerings to free packages. The first video on Laravel Heard is available at the time of writing of the article. I think there was also a video published yesterday or the day before at the time of this recording on Laravel's once helper as well. So definitely check all of this stuff out.

Michael:

The Laravel YouTube channel is a great place to keep up to date with the weekly releases in a in a more, code code code code friendly approach than what we do on on this version of the of the show. And, does tend to cover off some things in a bit more detail than what we do here. Here. So definitely check out that in addition to the Laravel News

Jake:

podcast. Absolutely. This one is an exciting one. If, you were at Laracon 2020 hold on. I'm I'm getting my ears mixed up.

Jake:

2023. I know. I had to think about it for a second. I'm like, wait a second. What was it?

Jake:

If you're at Laracon in 2023 in Nashville, native PHP was announced. And so that was really, really exciting. Right? What you could do then is you could use Electron, to ship a PHP application, a native PHP application to both Mac and Linux, I believe. But at that time, Windows support was not yet available.

Jake:

So it was announced, which means that you can now build applications for the Windows platform. It's working. And, and also along with the release of the Windows builds, we also get new versions of PHP to work with. So, PHP 8.2, 8.3, along with full Laravel 11 support using those, is now available as well. The announcement said this, I know many of you have been patiently waiting for this.

Jake:

Over the months, we've racked up quite a few issues as folks have attempted to find some way to get Windows builds working. Totally get this enthusiasm. Windows support was always on the cards, but we stated early on that Windows support was gonna take a while longer for one main reason, a lack of static builds for PHP for Windows with enough extensions baked in to support booting a Laravel application. So the the great news is you now have the ability to do that. To to start building for Windows, you have to make sure that you're up to date on the latest version of native native PHP Electron via Composer.

Jake:

So you'll have to compose or require that newest version. And after you do that, you can now also build for Windows even while on another OS using the OS argument via the build command. So when you're running your native PHP application, you're ready to build it, you can say, php artisan native build win. So this is awesome. Really, really cool stuff.

Jake:

The next question I have on this will be, how do I build this application in my GitHub actions? Right? How can I build it and then attach the executable to a release when I push to master? That would be my next step. And we will figure that out and let you know.

Jake:

I've got, an Electron app right now that's using Vue, and that's fine. That's fine. It's okay. But every time I have to jump back in there, I have to relearn kind of what we're doing with that thing. It's not that I don't know Vue, it's just it's a different beast.

Jake:

And so native PHP has got such excellent documentation, and it just feels so comfortable. Been waiting for this to release so that we could redo some of these things that we've built up with with JavaScript stuff with PHP now. It'll be a lot more approachable for all the developers on the team. And as well, hopefully, this GitHub action gets really easy to do because that's the other thing that we have, in our in our project. And so this seems it could be home run.

Michael:

Yeah. Excellent. Alpine JS has a new first party sort plug in added to plugging Plug in added to their ecosystem, which allows you to easily reorder elements using drag and drop functionality with your mouse. The sort plug in uses the sortable JS project under the hood for the heavy lifting of sorting elements and provides a really simple sorting API. So you can, on your unordered list, for example, say ulx dash sort and then attach sort items into that list.

Michael:

This small yet mighty plug in provides the ability to sort groups to cuss to provide custom drag handles, support for ghost elements, and customizable configuration for sortable JS. Calle Pazio has also created a screencast series on the Livewire site for the sort plug in and takes you deep into building a sortable drag and drop experience from the JavaScript all the way through to the database. This series consists of 11 videos with over an hour of content that talks through building a to do list, how to store the positions in the database using Alpine sort plugging, sorting items in the database. I really can't say plugging, can I? Extract a blade component, extracting eloquent traits, rearranging items, and sorting between groups.

Michael:

If you want to get started with the sort plugin, you can check out the Alpine documentation, and you can also find the sort screencast on the Livewire website. We'll have links to all of that for you in the show notes.

Jake:

Love that we get this stuff for free. Super cool. You get the sortable JS plugin for free. If you're looking for a way to support Caleb, go to that screen cast series. I believe those are, you know, a purchase sort of thing.

Jake:

Purchase those and throw a yeah. Throw a couple bucks his way. That'd be that'd be awesome. Show him some appreciation for the work that he's doing. And, also, he is currently working on jacking up his house.

Jake:

I don't know if you recently heard his most recent, notes on work episode, which is also one of my favorite podcasts to listen to. It's so fun where he just talks about the things that he's working on, and it's always the most random crap you've ever heard of in your life. And, yeah, he's working on jacking up his house because the floor is not level in his attic. And so follow along with the adventure and throw him a couple bucks of cash for his inevitable his the inevitable funeral that we'll be having when he collapses his house because he's jacking. Literally, dude, go listen to the episode.

Jake:

It's insane. He's jacking his entire house up. I'm like I messaged him, like, bro, you gotta stop this. We need you. Yeah.

Jake:

We need you around. Let let us pay let us pay for this.

Michael:

Let's let's not not the funeral. Let's assume that he gets out of it safely. He could he could jack too high, and then he's out of a house. Like, this is my builders do this because they're licensed. They're, like, experienced.

Jake:

Oh, no. Wrong. They're

Michael:

on the hook for it. But, no, Caleb Caleb do it yourself, man. No. I'm sure nothing will go wrong.

Jake:

Mm-mm. No. He's probably gonna wife

Michael:

lets him do this kind of thing.

Jake:

My wife Dude, I don't know. Oh, I know. I I don't think he tells her. It's very Are you

Michael:

doing nothing? Nothing. No.

Jake:

I'm not doing anything, honey. I'm just if you hear anything really loud, any really loud creaking from the house, it's ghosts. We're haunted. That's what it is. No worries.

Jake:

It's old house. Oh, moving on, folks. The April 2024 worldwide meetup, Laravel Worldwide meetup, is behind us. It was on April 29th. This one was written up by Paul Redmond.

Jake:

This was featuring Matt Machuga, and Mateus Guimarães. Do you know how to say his last name?

Michael:

I don't Mateus. Whenever he says his name, he says it respectfully in his in his own, native His

Jake:

native tongue. And Yeah.

Michael:

And and if you don't as someone who who speaks another language, I understand that, you know, it's it's fantastic that he says, I can't. I'm sorry, mate.

Jake:

Yep. Yep. True. It's one that I

Michael:

can't get my tongue around.

Jake:

Yep. Exactly. And so I well, I think Mateus and I might follow each other on Twitter or something like that. I know Matt Machuga, and I just gotta tell you, if you've never met Matt Machuga, you're missing out on a large part of life because this dude is a freaking rock star. He was the guy back in the day that was, like, on the IRC channel all the time.

Jake:

And if anybody ever needed help, Matt Machuga to the rescue. That guy was awesome. And then he was even better in person. I met him at Laracon. He's like, no way.

Jake:

Hey, Jake. I'm like, dude. How does this guy even know my name? Like, he knew people, and he was just, like, a huge community guy. Just brought people in.

Jake:

Nicest dude ever. And so, huge shout out to Matt Machuga. Definitely go check this one out. Super cool talks too. So Matt Machuga had in some insights on scaling a web application in his talk, oh, crap, were popular.

Jake:

And so he, I've looked through his slide deck, really fun stuff, very entertaining. And then Mateus takes us on a look inside the framework with his talk entitled, an introduction to Laravel internals, where he does some source diving. And, it's also well worth checking out. So if you are looking for that, you can visit the official page for complete details at meetup.laravel.com. You can also submit your talk for a future meetup if you'd like to.

Jake:

So that's a good one. Check that out. Perfect.

Michael:

On to our good friends at Mailtrap. This episode is sponsored by Mailtrap, an email delivery platform that developers love. They're an email sending solution with industry best analytics, SMTP, and email API, SDKs for major programming languages, and 247 human support. Try for free at Mailtrap.io

Jake:

Thank you, Mailtrap. Folks, have you ever thought to yourself, you know, I just don't have enough options when it comes to admin panels for Laravel. I think I need another. Well, if you've said that recently, boy, do we have some good news for you because Moonshine is an open source admin panel for Laravel. So let's talk about it.

Jake:

So this is an open source package for Laravel, which offers an admin panel that you can use for MVPs, right, minimal viable products, back office applications, content management systems, and allows you to make an admin panel with authorization and CRUD, here's the promise, in minutes. So it's a tool for rapid development using the packages of CMS features and other features that make you productive using familiar tools like Blade, Livewire, and Alpine. So it sounds like a tall stack. There's no binding to models. You can take whatever data you like.

Jake:

So it's not necessarily just strictly related to, your eloquent models. It's got a form and a table builder. It's lightweight, really easy to integrate your own Alpine JS. It's got Tailwind CSS and Blade, so you can use your Tailwind UI stuff in there. It's got the ability to use Blade and Labar components and a template builder, so you can change colors and overall design by just applying a new template.

Jake:

Pretty cool. So to start with Moonshine, check out the installation guide. You You can do that at moonshine dash laravel.com. Documentation is another good place to start with the Moonshine 2 video guide, which they've got on the YouTube channel. Check that all out in the show notes on the blog there.

Jake:

Thank you, Paul Redmond, for writing that one up, everyone's favorite human.

Michael:

Excellent. Another article here from Paul Redmond is on the Laravel slower package, which is designed for Laravel developers who want to enhance the performance of their applications. The package identifies slow queries and suggests optimizations such as indexing and other improvements using AI. Depending on how you configure your application scheduler, you could run some of these commands each day to analyze and clean up old records. There is PHP artisan slower colon clean and slower colon analyze.

Michael:

The recommendations that are created with the slower colon analyze command are stored in the database table created by the package which you can review after AI analysis is completed. As part of the analysis, the package's main features include a configurable slow threshold, configurable AI AI models like chatgbt4, the ability to disable AI and only log slow queries, configurable prompt for the AI analysis, and the ability to disable the slow query analysis. Readme includes an example analysis to help you visualize what you can expect with the package, which we will include here in the show notes. You can learn more about this package and get full installation instructions and view the source code on GitHub.

Jake:

Very nice. Moving along with packages here. And speaking of AI, because who doesn't love AI? Right? We all love AI.

Jake:

We love AI. There's this thing called replicate, which I'm not exactly sure what this is. I'm I'm looking at it. So I'm gonna read you the the bullet not the bullet point, the elevator pitch for it. Here it is.

Jake:

Run and fine tune open source models, deploying custom models at scale, all with one line of code. So run an AI with an API is the idea here, right? That's the title here. So what this is, is this is a Replicate Laravel package. So it's a PHP client for the Replicate API, right?

Jake:

It's a little SDK wrapper around Replicate. So again, an API to run and fine tune open source AI models. So there is a quick example from the readme, using the replicate Laravel client. So the different methods that you can do, so you could say replicate, create a model, and then you pass in some data there. And then you can get response methods like, give me the body, give me JSON, collect the values.

Jake:

Successful? Was it a redirect? Did it fail? So the Laravel client has the following endpoints available to you. Account models, predictions, trainings, model collection, deployments, model hardware, and more.

Jake:

There Laravel kind of tells you the different usages that you might want to use. So like generating images, or text, or videos, or music, or speech, and more, using thousands of different community models that are available to you through that replicate API. So just start using replicate Laravel in your own applications, check out the package at well, you know what, I'm not gonna read that. You should just check it out on the blog posts. If you want access to all of these open source models, you wanna access them through an API, replicate API is the thing to use.

Jake:

So check that up.

Michael:

Amazing. Lastly, today, the directory tree authorization package by Steve Baumann is an easy native role and permission management system for Laravel. It works with Laravel's gate and authorization methods out of the box and offers a lightweight API to help you manage your roles and permissions. You can use permission create, which is a model to create new permissions. You can use role create, which is a model to create new roles.

Michael:

And you can associate permissions to roles and to users, and then you can check against the authenticated user, or you can use gate allows, or the at can blade directive in your blade views. This doesn't contain every method available. You can see the readme for usage details on managing roles and permissions with the package, which includes managing user roles and permissions, creating user specific permissions, checking permissions and roles, caching permissions by default, which is important for performance, of course. You can use it with Laravel's native gate and authorization methods. Permissions are registered in Laravel's gate by default and includes useful permission and role middleware that you can use in your application straight away.

Michael:

You You can get started with the package by checking it out on GitHub at directory tree slash authorization with a Zed Or is it

Jake:

I think

Michael:

prefer, but not an s.

Jake:

What would you say here is the differentiator that they're trying to make between this and something like, Joseph Silver's, like, bouncer or, you know, the SPAC permissions stuff. Can you I I I have a hunch. I'm just interested what your thought is.

Michael:

I think I think, you know, some of those things can provide a lot of functionality, sometimes functionality that you don't need. Now there is consideration to be made on a project by project basis as to whether you think you'll grow into that extra functionality. Or if you think, you know, it's a really, really simple application, I guess, for lack of a better word, it's like, this is what I'm going to use. And this is all I'm ever going to need. And I'm not going to grow into additional levels of, you know, management and functionality and things like that.

Michael:

So roles and permissions are always a tricky thing because you need to kind of consider what you're going to do because unwinding them, changing them, replacing them at a later date is tricky. So, you know, and it's hard, it's hard to know at the start, where you're going to end up in 6 months, 12 months, 5 years, you know? So, yeah, what what's what's your take, do you think?

Jake:

I think and I'd have to go back and look at some of those other ones. But I kind of feel like you would have to do, maybe with those other packages, you'd have to sort of check permissions and things in a way that was specific to that package. So you'd say, like, user, and then you'd have some special interface that or maybe a trait that you'd implement on the user, that would give you some special methods that you would use to check ability to do particular things. Right? And so it would go in and look at its own stuff.

Jake:

I think what this does, which is interesting, is it uses all the Laravel way of checking permissions. Right? It uses like the can directive, or it uses those gates, or it uses, you know, authorize. That sort of stuff. Like, it feels, once you've got it set up, it feels pretty lightweight.

Jake:

It feels like what it would be like if you were just registering these things manually yourself. And then I think also it maybe

Michael:

feels

Jake:

really familiar, because, like, when they're setting up a permission, you're literally creating a model, permission create, and then there's a name and a label. That's it. And when you're setting up a role, you're literally creating a model, role create. It's just enough and nothing more is what it feels like. Right?

Jake:

And so anyway, it's interesting. I've used Bouncer, I've used Spasie's permission stuff, but I'm looking for a more permanent solution as I I only have implemented that in a couple places. And maybe I'll maybe I'll check this one out. So Yeah.

Michael:

Yeah, we're we've got a we've got a big piece of work coming up to kind of figure out how we're going to create, use, manage, implement, you know, all of this kind of stuff coming up in the next 3, 6 months, I guess. So it's a lot of lot of things. I'll I'll probably end up working with my team to go through a few different options and see where we wanna land and how much detail we wanna go into. And and even how much we allow users to control their own permission sets within roles and things like that. Okay.

Jake:

Sure.

Michael:

So, you know, we'll have we'll have a default. We we talked about this briefly. We, you know, we're gonna have a default set of permissions for a week for we call them groups, but they're effectively teams. And then, you know, each group will be able to manage what those permissions are under their own sort of tenant situation. So it'd be interesting to to say what in I was this for us the best.

Jake:

I'd love to hear about that. Yeah. We'll talk more about that on our North Meet South podcast. If you wanna hear about that, check it out over there. Alright, folks.

Jake:

That is it for today. Can you believe it? Michael, what's our time? What do we got?

Michael:

Oh, we're at 27?

Jake:

Oh my gosh. We're going to finish in under half hour. Should I jinx this? I'm not I'm not gonna jinx this. Folks, this is episode 214.

Jake:

Thanks so much for hanging out with us. You can find episodes for this so you can find episodes. You can find show notes for this episode at, podcast.laravel-news.com/214. And, if you liked this podcast, let's be honest, you love this podcast, you should go rate it up in your pod catcher of choice. That's 5 stars.

Jake:

5 stars would be great. 4 and a half, nah. If you're feeling really mad at us for some reason, give us 4. But just go just go give us a review. That'd be that'd be incredible.

Jake:

And, of course, if you wanna hit us up on Twitter at Jacob Bennett, Michael Treindor, or at Laravel News, all those are viable options. Or Eric Barnes, if you wanna talk to him too. He's on there. He's making content. He's a dude he's a good dude.

Jake:

And Paul Paul Redman. I mean, listen. This thing would not exist without Paul Redmond because Paul Redmond is, like, writing, like, 90% of these articles. The dude's a rock star. Thank you, Paul, everyone's favorite human.

Jake:

And thank you, Mailtrap, for sponsoring again. Alright, folks. Until next time. We'll see you later. Bye bye.

Jake:

Bye.

Creators and Guests

Michael Dyrynda
Host
Michael Dyrynda
Dad. @laravelphp Artisan. @LaraconAU organiser. Co-host of @northsouthaudio, @laravelnews, @ripplesfm. Opinions are mine.
Anonymous broadcasts, sorted elements, and Moonshine
Broadcast by