Laravel 11, Flat Camps, and enriching queries

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. Hello, everyone. We are live with episode 211 of the Laravel News podcast. Today is March 26, 2024, March 27th, if you're in the upside down. Michael, how's it going, my friend?

Michael:

Going well. Days are getting shorter here, though. Mhmm. And the it's it's it's almost at that point where it's dark when you wake up and dark when you go to bed.

Jake:

No good. I don't like that time. But, you're up and out early. Yeah. Right?

Jake:

Running out there. You still do the running thing?

Michael:

Well, I woke up yesterday to go for a run, and I got out of bed.

Jake:

Running and walking the dog. Maybe you're walking the dog.

Michael:

No. Not walking the dog. Yesterday was a run. And and I got up and it was like 12 degrees Celsius. And I got out of bed and I was like, no, I could I felt cold inside.

Michael:

I'm I'm not going outside now. So I went for a run a little bit later and had a good run-in the in the middle of the day. But I just felt out of sorts, like moving my run from first thing in the morning to the middle of the day, I just felt all out of sorts first thing in the morning. So trying to avoid that.

Jake:

Good on you. But I

Michael:

think it's getting to that time of year where it's gonna be time to shelve the run.

Jake:

Yeah. Yep. Good on you for the for the running. That's that's a good thing. I my son is in track right now.

Jake:

And he decided that he wanted to race me. And so he's just trying to run around the block or, you know, he's trying to run at least a mile a day kind of thing. And so around a block is like half a mile. And so he went out and timed himself and he was at 3 minutes 30 seconds. And I thought, okay, I'm I'm gonna have to gut it out.

Jake:

I can do this. And I started out at a really good pace. And then like a quarter of the way around the block, I was totally dead, just completely gassed. And I was like, dude, I gotta do this more often. Yeah.

Jake:

But I couldn't I couldn't stop. Right? I couldn't stop myself. I had to keep going. So he beat me by 12 seconds.

Jake:

So I've got a new goal. I've got a new goal to get around the block in 3 minutes 30 seconds. I gotta be able to beat him still. He's only 13, you know? So can't let him win yet.

Michael:

Not yet.

Jake:

But, exactly. Yeah. Gotta beat your son in the best sense of the way. Hey, folks. Wanted to give a quick shout out to Century as well who is sponsoring the podcast.

Jake:

They are back this year sponsoring Laravel News Podcast for the entire year. Thank you so much, Sentry. I've been using Sentry a ton this week, actually, to surface errors in my applications. And, we're upgrading to Laravel 11, so I rely on Sentry to help report errors before my users have to, which is really great. They actually have a really good way to add context along with the errors that you're experiencing inside of your application.

Jake:

And I'm in talks with one of their developers about possibly making it so that you can just use this brand new Laravel context that was released within the last week, and that will automatically add the context to the Sentry exceptions. So that will be great. If that does happen, you'll hear about it here first on their videos. So Sentry. Io, check them out.

Jake:

Thanks for sponsoring the show, Sentry. Okay, with that out of the way, we've got releases, news, and packages, tutorials. I don't want to say that we have a light week, because every time we do, we end up running over. But you already said it earlier, so I'm gonna say it. We have a little bit of a light week.

Jake:

So let's jump into it and talk about resources for getting up to speed with Laravel 11. My friend, mister Durinda here, is having a problem with his camera. So hopefully it comes back. Those of you who are watching this on YouTube in the after, after the fact, we'll just have to deal with the Elgato logo. And until then, we'll talk about some resources for getting up to speed with Laravel 11.

Jake:

So this was written by Paul Redmond on March 12th. Now Laravel 11 is out. Here are some resources from the community for getting up to speed with Laravel 11. This is for this is good for people who have been using Laravel for forever or anybody who's just jumping into Laravel 11 to start with. So here's some handpicked content we think will help get you up to speed quickly.

Jake:

Laravel 11 highlights in 90 seconds. So if you're already familiar with Laravel, we're gonna walk you through these 11 highlights in 90 seconds, thanks to Laravel News, talking through those. The streamlined directory structure that's available in Laravel 11, Eric has a video on that one as well. Eric Barnes, our fearless leader, diving into that new streamlined directory structure, which I've got to say, after upgrading a couple projects from Laravel 10 to Laravel 11, I really, really like it. It's a little bit uncomfortable at first, I feel like.

Jake:

But once we get past some of the little changes, it feels so good. So we have almost no service providers anymore. We're really down to just a few, and the rest of it is either auto discovered stuff. So like the event service provider is completely gone. All the event, all the event listeners and observers and things like that are either handled in the bootstrap file or they're auto discovered, which is great.

Jake:

And the config options are all gone, which feels really good. So really, really cool. Over on the official Laravel YouTube channel, you also have Christophe Rumpel walking through the new features that landed this week in Laravel 11's release. And then you also have another one by Josh Saray, an excellent roundup of the high level features released in Laravel 11. You also have Laracasts 30 days to learn Laravel.

Jake:

And I think this one, I don't remember if this one was done by Jeffrey or not. Let me see here.

Michael:

Yeah. The 30 days is is Jeffrey.

Jake:

Mhmm. Yep. But I think the changes, to Laravel 11 inside of Laravel News, that one was done by the other guy. What's his name? I'm blanking it now.

Jake:

Thank you. Luke Downing. Yep. And He does a really good job. I rolled through that whole one.

Jake:

I had my whole team, my whole development team, run through that. And it's like, I think if you listen to it at 1 dot, like, 1 and a half speed, it's like 50 minutes for all of it. And he goes through literally all of it and all the changes in Laravel 11, between Laravel 10 and Laravel 11. Would highly suggest watching that one. So lots of great, videos here to watch.

Jake:

There's also one on reverb as well, and then a video on how you can update from Laravel 10 to Laravel 11 using Laravel Shift, thanks to Jason McCreary and his awesome, awesome platform. We use it for all of our shifts from 10 to 11, Would highly suggest doing the same. I I would also push you to this as well. If you're if you're thinking of upgrading to Laravel 11, from like Laravel 10 or something like that, honestly, even further ones back if you want to. There is a, can I upgrade Laravel yet on Laravel shift, which you just paste in your composer dot JSON?

Jake:

And it'll tell you if the versions of the packages that you're running are compatible with the latest version of Laravel, which is really helpful for us because sometimes they're not. And so you need to go out there and check to see if those packages are up to date with a Laravel 11 tag or something like that. And if not, then, you know, maybe you ping the authors and and things like that so you don't get halfway through a shift and then realize, oh, no. I can't can't do anything with this, and you have this still pull request sitting out there. So, that's a really helpful site.

Jake:

And then also mentioned in the notes here are Laravelversions.com and PHPreleases.com, which both, have information on the stuff that we're just talking about, supported PHP versions, supported Laravel versions, etcetera, on and on we go. So there is that one. Lots of good videos there. If you're looking for, if that's, like, your cup of tea for how you like to be updated on these things video. Definitely go check this blog post out.

Jake:

Okay. Over to you, mister Dyrynda.

Michael:

Excellent. The first kind of major, I suppose, feature that we've gotten since Laravel 11 was released is this new context facade in Laravel 11. So this is a service to define contextual data attached to your current request, request, and that contextual data is then included in all log entries for the request or queue jobs will also retain that data. And using contextual data allows you to easily trace back code execution from the point that that request came in all through any distributed flow. So this is really useful for tracking host names, trace IDs from CloudFlare, attaching things that kind of traverse through your systems.

Michael:

So if you have a have a request that comes in that then dispatches a job, you can track, okay, this request, triggered this specific invocation of this cute job. And if that goes and makes a HTTP request, you can attach to the context to that if you if you've traversed another system, like for example, where where you are, Jack, I know that you've got a few few systems there that requests might come in and then bounce around 2 or 3 other different locations. You can track that all the way through. And then if you're using something like Sentry, where that contextual information that's bound to that request, you can track it all the way through the flow wherever it bounces around. So you can search for that context ID and things like that.

Michael:

We've done a similar thing to kind of track things through our application in a couple of places where we can track a request that comes through that hits another internal service that then responds back with some data. So we can say, you know, what was the original request. And if if a 500 is raised somewhere down the line, we can say, okay. This this front facing service received a, you know, a generic 500 level error from that internal service. But then we can see for that contextual ID, what the actual error was on the internal service.

Michael:

So it's extremely useful in situations like that. There are all kinds of creative ways of using it. I know David Hemphill was tweeting the other day about some what some considered to be abuses of contextual data.

Jake:

I thought it was genius. I thought it was really cool. Actually.

Michael:

I thought it was clever. I think it's it's not really up to the framework to dictate how you use that contextual data as as with anything, the framework provides you the tools, right? And then what you do with those tools is entirely up to you. So definitely check it out. This was a brainchild of Tim McDonald's.

Michael:

He's been sort of percolating on the idea for quite a while. And it's nice to say that this is finally out and certainly a very useful thing. And hopefully in the near future, our friends at century will incorporate this contextual stuff into their exception handler automatically so that all of that information just gets carried through.

Jake:

Yeah. Yeah. It sure would be nice. It's it's not like it's impossible to do so currently. Like, you could do it, like, in in your, it's in the app dot or it's in the bootstrap slash app dot PHP.

Jake:

There's with exceptions now is one of the fluent chained methods on there. And then you just set the so you can set the cut set the sent to context right there. But, if it just did it, that would be really, really cool, actually. So, yeah, something to, something to weigh on and hopefully hopefully see that in the near future. I know Tim I had messaged I think I replied to a thread that Tim was in and said something about that, and he was like, yeah.

Jake:

That was one of the hopes of the original, like, implementation is that the air trackers would do something like that. So interesting one for sure. For sure. Okay. Let's talk about Laravel Herd.

Jake:

So if you've been living under a rock since, the last Laracon in the US, Laravel Herd is to replace basically is, a valet replacement, a drop in valet replacement. It's got a lot of incredible features we've been talking about on the show for the last year, 3 quarters of your last half year, whatever it is. But there is this Laravel Herd Pro, which has even more features. So the headline here is no more Docker, no more DB engine, no more homebrew. So Laravel Herd 1.5 introduces an exciting new pro feature, which is services.

Jake:

If you've ever used something like DB engine before, you know that you can see the different MySQL servers or, you know, different things you can spin up through there. But Herd will replace all of that for you. You can easily create and manage all of those local development dependencies, such as databases, Redis, Minio even, so like S3 storage services, like Minio. So this is, one of those things I would always have to, like, spin up sort of on the side and like, oh, I don't start it with my machine, so I'll have to spin it up now. And this just all ships now with Heard if you are using the pro feature, which I have purchased recently, and have been very impressed with it.

Jake:

And so it also has real time services like Laravel Reverb. So if you know you're going to be using Reverb, you can just add it. So it really is this first party local development workflow that's just so tailored to Laravel development, and it really feels seamless. I really, really enjoy it. So I've been using it for a little bit.

Jake:

The The other thing I want to bring up here, which I don't know if it's later on in here or not, I haven't read through the whole article, is that it's on Windows as well. As of this, as of the time of this recording, it's available for Windows.

Michael:

Next article. Next article.

Jake:

Next article it is. So anyway, it manages all these services we've been talking about for you. No Docker, no Homebrew, all that stuff. It also provides all the configuration and the logging that you need to set up and monitor to configure your app. So there are details on the Heard Pro services and the official documentation, but can't say enough good things about it.

Jake:

Really, really exciting stuff. And definitely go buy a Herd Pro if you can. It is, $99 for Herd Pro. And if you have a team, you get 10 Hurd Pro licenses for $300. So it's a steal of a deal because we, I mean, we save money on it.

Jake:

We have, you know, 4, 5, 6, whatever people that we've given licenses to. And for $300, you're basically getting it for half off. So really, really good stuff. Definitely go support the team there. Great work.

Jake:

To all the folks that are working on that, Marcel and, Diana, I think are working on that one. So great work on that.

Michael:

And Sebastian.

Jake:

And Sebastian. Thank you. And Sebastian. It's always scary mentioning names because you'd always you know you're gonna always forget one. So

Michael:

Oh, no. You don't wanna forget anyone.

Jake:

I know.

Michael:

As you mentioned, as of today, Laravel Herd is now also available for Windows. It is the fastest environment around. It's using native binaries. To to recap a little bit, it's using native binaries for PHP and NGINX and other services that makes it faster than any other PHP development environment. There are no containers, no VMs or wonky virtualization methods, just plain binaries that are all shipped as part of Laravel herd.

Michael:

It gives you everything that you need to get started, including binaries for composer, the Laravel installer expose, they're all automatically included and available on the command line. And it makes it possible to manage your sites via PowerShell or using the herd site wizard. And as I mentioned with, pro, you've got the additional functionality for managing databases and caches and logging and dumps, basically giving you an all in one place for all of your Laravel development needs. And as of today, it is available for Windows. So free version, install it.

Michael:

Someone I think Marcel tweeted that someone just got a new computer, And they installed heard and they were up and running in 2 minutes where previously they'd use, I think, sale or something. And it would always take them a couple of hours to get it going. So this is a install, set up, run, everything's available. It gives you per site level isolation of NPM and of PHP version, so you can have different versions running at the same time. You know, people often ask why why not use Docker or anything like that.

Michael:

For the majority of cases, it is much, much simpler. You don't have to create your Docker files. You don't have to do any of that stuff. It's all just available when it all it is all managed for you. So entirely up to you which approach you want to use, of course.

Michael:

But now available on Windows, people are asking about Linux. I think there is kind of sort of plans to do it. My the first thing that pops into my head, and I'm glad I'm not the one responsible for building Laravel heard, is which flavor of Linux is this gonna work for? So Mhmm. Congratulations to, Marcel and Sebastian and Diana, for the for the work that they've put into getting, Laravel heard for windows shipped on their original timeline of March, which we all know in software is an, is an achievement in an, in and of itself.

Jake:

Yes.

Michael:

And, have a bit of a break before you start tackling Linux.

Jake:

Very good. Hey. We're gonna talk about statemix here. So if you've not ever used Statamic before, we've talked about it quite a few times on the show before. But, specifically, here, we're talking about statemix flat camp.

Jake:

So this is a relationship focused retreat for Statamic and the Laravel community, which is gonna be happening in a EU version, June 11th through 14th this year, which is is set in, the idyllic Italian countryside right outside Rome, surrounded by beautiful scenery to talk business and non business. So you get to spend time with the Statamic core team, meet lovely people from the community in real life, influence the future roadmap, talk about operating your freelance business, etcetera, etcetera, all that good stuff. There is a recap of the flat camp from last year, what they did outside of, just actually, sorry, on the Blue Ridge Mountains in North Carolina, and have some photos and pictures there. And if you still need convincing for why you should go, Jack McDade, the founder of Statamic, will tell you why and do some convincing for you on your behalf. Send this to your boss.

Jake:

It's limited to 50 guests, so you want to make sure you get it as quickly as possible. It includes 3 nights of lodging, as a private chef, all workshops, intimate talks, wine cellar chats, etcetera. The list goes on. You should definitely check it out. If that's something that sounds interesting to you, you can check it out at flatcamp.com.

Michael:

Perfect. Next up, caniphp is a Raycast extension written by Diana Scharf that lets you check a certain function or method is available in different versions of PHP. So essentially, you can open up, Raycast, which we've talked about on the show previously, I think, which is like an application switcher. But with all of the extensions, it does a whole bunch of stuff, all from this little command palette. And you can search for a PHP function, and it will tell you in which versions of PHP is available.

Michael:

So nice tabular tabular view, and it will show you PHP versions, you know, 7 4, 8.0, 8.1, 8.2, 8.3, and highlight in green all of the supported versions in a nice little matrix there. You can also get a helpful details page from the caniphp.com website. And the caniphp API is like, can I use, which if you've used for on the on the front end, like, for HTML and CSS features to see which which versions and which browsers support different things? The alternative to this extension, of course, is to manually look up the PHP documentation and find when something was introduced, which can be a little bit tricky sometimes. It's not always clear which specific version something was released in.

Michael:

But to get started with the extension, you can search the extension, the Raycast extension store for Can IP HP, install it and off you go. The right the source code is available in GitHub. So if you do find any issues with it or you wanna contribute some features, you are able to do that as well. Raycast.

Jake:

You don't have it does does cost anything currently. You can pay for the, like, the pro version, but it has been really delightful to use. And this has replaced a lot of the other tools that I had that were just kinda hanging out there on their own. It's just kinda collapsed that to be all in one spot, which I really like. So definitely check out Raycast and definitely check out that Can I PHP Raycast extension?

Jake:

Okay. Speaking of there's no transition here. There is no speaking of. It's just the Laravel worldwide meetup was today is all it is. And, our good buddy TJ Miller, who is just a rock star of a dude, out of Detroit, super nice guy and insanely smart about artificial intelligence stuff.

Jake:

He Michael, you and I, how many days in a row have you gotten messages from TJ? Just randomly just he just throw stuff about AI and his little thing, his little LLM that he's training in. It's it's just delightful, like, to watch him just

Michael:

exploring

Jake:

yes. Yeah. Explore the crap out of this thing. And so At

Michael:

least the last 6 weeks, like, publicly in our chat?

Jake:

Yeah. Yeah. And I mean, even before that too. I mean, he's been doing playing around with this stuff for forever. So, today, he talked about how you can bring AI to your Laravel application.

Jake:

So, I have not yet had a chance to watch this. I didn't get to watch it live. I'm actually on spring break in Virginia today, recording from there. So I didn't have a chance to watch it while I was on the road today, but really excited to get in there and watch this. He's I'm sure he did an incredible job and, really excited to watch this one.

Jake:

So if you have not yet, go ahead and check that out, please, at meetup.laravel.com. Check that one out. TJ Miller, give him a shout out on Twitter. Super good dude. Congrats, TJ.

Michael:

And also, if you are interested in dipping your toe into the speaking circuit, The Laravel Worldwide made up is a good way to kind of get started to try out some material to, you know, see if speaking in public is something that you're interested in, kind of before taking the plunge to speak in front of a live audience. So very supportive. Talks can range from 30 minutes to an hour. I think last time around, they had a couple of longer ones. TJ's was about 40:40 minutes, I think.

Michael:

So definitely check that out. They run, I think, monthly. So if you check it out at, was it meetup.laravel.com? Mhmm.

Jake:

Yep. Meetup.laravel.

Michael:

Out not only today's, but also all of the previous, editions of that made up. So check it out. On to the packages. Tableau kit is a series of UI components for the Tableau admin dashboards. So Tableau, if you're not familiar, and I am one of those people that is not familiar, but we spoke about this last October, it is an admin dashboard package.

Michael:

That is beautiful, feature rich, and uses Laravel Tablar Dot Tabler, I guess Tabler.

Jake:

Tabler. Maybe that's what it is. And

Michael:

Vite. Yeah. In Tabler, you can use a free open source web application UI kit based on Bootstrap 5 with hundreds of responsive components and multiple layouts. But the UI kit here that we're talking about today adds many easy to use components, making your dashboard more visually appealing and user friendly, and it's all about simplicity and enhancing your experience with Laravel Tableau. There is standard form components and advanced drop down file upload with on the fly image editing, optimized data tables with export options, rich text editor with file upload and browser features, and, responsive and customizable design.

Michael:

The tab Tablar UI kit provides Laravel blade components and all of the required JavaScript required for the components to function. And it's as easy as adding, for example, a tape picker. You can say x dash flat dash picker as your component or a light picker. You can bring in Filepond or Jot It, which is a WYSIWYG editor. So if Tableau is something that you have used or have had a interest in, if you need to build an admin dashboard, if you are using Bootstrap, then this may be something that gets you where you need to go quicker than you would have doing it from scratch.

Michael:

So check that one out.

Jake:

Very cool. We're always talking about databases on here, aren't we? Databases are sort of like the, it's like the brain of your application, right? And so, it's really important that we understand how to work with databases and how to utilize them best. Well, this package is called Laravel query enriched and it's designed to easily create complex database queries in Laravel, without having to write these complicated SQL statements.

Jake:

So some examples taken from the remain. And really, I mean, that's the pitch. But where I'm interested in this is if you're wanting to sort of eject out of the eloquent sort of set of queries and the query builder sort of stuff, and you're wanting to really get down into the database level. So you have things and queries that are given to you that you want to leverage the database to handle for you. Right?

Jake:

So it facilitates that optimization, right, by ejecting and saying, I'm not gonna use Eloquent necessarily. I'm not gonna, you know, loop over these things and do this myself or, you know, do an average after I grab them out of the database. I just want to use the database's average function. Right. One way you could do that is you could just do DB raw, right, and you can use an average function in a DB raw statement.

Jake:

You can do that, but you could also use this, this query enrich will allow you to do that. And some of the things that it allows you to do is you're not hard coding, these SQL statements, but it also ensures cross database compatibility. So this is one of the things that's difficult is if you're switching from like MySQL, but you're running your tests in SQLite, maybe there's not always necessarily a one to one translation of some of these raw things that you're trying to do in DB raw into SQLite. So you can't use SQLite, you have to use SQL. So that's annoying because with Laravel 11, they just shipped something with SQLite that makes your memory tests like twice as fast.

Jake:

So you'd really like to be able to stay in SQLite land for your tests, if at all possible. It'd be really nice. And so this also helps to do some of that. It also makes your code a little bit easier to read. And, you know, ultimately what we're after as well is better performance, right?

Jake:

SQL databases are designed for data manipulation and retrieval and, you know, pushing logic into the database. And so this helps to make that easier for you. So that's, that's the pitch as I'm reading through this. That's that's really kind of what we're getting at here. So the post is really just taking here's something that you would have written raw.

Jake:

Here's how you could write it, with, you know, with Laravel's database builder. And then here's how you could write it with query enrich. It is quite code heavy, so I'm not going to go through each one. What I'll say here is that some of the things that they're using as examples are things like, taking now and then subtracting an interval of days. Right?

Jake:

How would you do that with a raw statement? And then here's how you would do this with, with Query Enrich . Like we said before, grabbing an average, how would you grab an average? Well, again, sometimes you would grab that all out and then you loop over it, or sometimes you do a raw statement, or you can just do a query enrich, which is really cool. Or they have one here.

Jake:

Let's see. Oh, a, I think there's, like, a case when statement as well. So if you do just something something like that. So anyway, you know, the different examples you can think of, concat is another one that you might that you might, end up using. Query enrich, helps to facilitate, creating those raw queries without locking you into a specific vocabulary, or I'm not sure what you even call I can't remember what you call that.

Jake:

Just the different words that are used between the different database engines, you know, SQLite, MySQL, Postgres, whatever. So

Michael:

In the Laravel context, it's typically referred to as grammar.

Jake:

Thank you. Grammar, not vocabulary. Grammar. You got it. Nailed it.

Jake:

Okay. To you, my friend.

Michael:

Excellent. Yeah. I think the the key thing here, if you are writing those those kinds of things manually, if you're switching between SQLite in development and MySQL in production, that you may find yourself triggering errors. And as a result, something like Sentry from our friends at sentry.io will give you the ability to have complete stack traces to see local variables in the stack for your production errors just like in your development environment. You can explore the full source code with context to frame the the sort of error that has occurred, and you can filter and group those exceptions intuitively to eliminate any noise so you can track down those SQL errors directly.

Michael:

It'll also expose the important events that led to each Laravel exception, network requests, SQL queries, debug logs, post errors. You can find out what version this was introduced in so you can track down the issue and squash it quickly. If you sign up with the code Laravel News, you will also get 2 months free. So check them all out. The incredible feature set, always something new coming, performance monitoring, insights.

Michael:

It's not just a log viewer. It's not just an exception tracker. Thank you to our friends at sentry.i0.

Jake:

A couple of things that I've really liked about Sentry is that I can go into my list of errors. And if you're like me, sometimes, especially if you have JavaScript errors turned on, there can be a lot of noise. So one of the things I like to do is I like to sort by what was the most recent thing that happened. And then also what's the frequency. If you have a set of errors that's like your application isn't necessarily like down and broken, but maybe you're throwing some exceptions that you're handling, Sentra makes it really easy.

Jake:

It says sort and filter. It really does. Like, I use that all the time. There's also tags and things like that that you can add on to them to give you additional filtering options. And then the releases is pretty cool too.

Jake:

So you can see this error was first introduced when this release took place. And then you can click into that and you can see the code that was committed. You can see who is responsible for it. It will even allow you to auto assign issues. If you use their GitHub integration, you can say assign an issue to the person who changed this code last, which is really nice.

Jake:

So, allows you to expedite that process of taking those bugs and getting those to the person who can most effectively solve them. So, thank you again, Sentry. Really, really good product. Please go check them out at sentry. Io.

Jake:

Okay. Caching routes with Cloudflare. I think this one is you, my friend.

Michael:

Yeah. The Cloudflare cache package for Laravel provides cacheable routes, allowing you to serve millions of requests for static pages efficiently. You can define a group of cacheable routes with the Laravel router, including tags, and the package makes it easy to start caching with Cloudflare using the route cache method. The package will give you an API to purge all content, specific URLs and prefixes and tag URLs if you are on an enterprise Cloudflare plan and more. So say you wanted to cache posts or articles with Cloudflare and then purge the cache whenever an article was updated.

Michael:

You can simply, in your update, your controller update method, carry out your update operation, and then call Cloudflare Cloudflare cache colon colon purge by URLs and pass it the route that you need to purge. And then that will send off the request to Cloudflare in order to purge the cache of that specific URL. So you don't have to do what I do manually as part of my deploys and and purge everything. You can just target that specific URL and off it goes. You can learn more about the package and get full installation instructions and view the source code on GitHub.

Jake:

Very good. Well, hey, last thing we've got here today is a tutorial to talk about managing time zones within your Laravel application. So in this video, Ben Hulman teaches us how to manage time zones in your Laravel apps. Here are some of the tips he gives, storing all dates and times in UTC. Michael, do you do this?

Jake:

Just store dates and times in UTC? Oh, yeah. No. I don't.

Michael:

So Not at work, but anywhere anywhere else that I'm

Jake:

Yeah. The good news is, you know, if you know what time zone your storm is, you can always you can always convert them to be in UTC. So that's the first tip. Store all dates and times in UTC. Then define a default application time zone.

Jake:

So you store in UTC, but then you can define your default application time zone and then you can use carbon macros for conversions, or you can either manually or automatically, set the time zone for users based on when they sign up, if they put in their time zone, or you can allow them to change it after the fact. There's some code samples, that he gives in the video that are here in the, in the blog post as well. We are actually going to be setting off on a greenfield project here in the near future where I'm going to have to be much more cognizant of time zones. So this is a very timely tutorial on how to use time zones efficiently. It's a lot easier to do it if you're starting if you're starting out doing it rather than trying to do it after the fact.

Jake:

So thankful for this one. Thanks for Eric.

Michael:

It's very hard to retrofit it.

Jake:

It is. It is. So thanks to Eric for writing this one up. Thanks to Ben for creating that video. Folks, that's all we got.

Jake:

Michael, you got anything else for us today before we wrap it up?

Michael:

I have nothing further.

Jake:

You have nothing further, folks. Thanks so much for hanging out with this. This was episode 211, March 26th. If you have anything you'd like to hit us up with on Twitter, hit us up at Jacob Bennett and Michael Dyrynda or at Laravel News. Show us where this episode will be found at podcast.larvel-news.com/211.

Jake:

And if you liked it, please rate us up in your podcast of choice. Check us out on our YouTubes, all that good stuff. Wonderful hanging out with you folks. We'll see you in 2 weeks.

Creators and Guests

Michael Dyrynda
Host
Michael Dyrynda
Dad. @laravelphp Artisan. @LaraconAU organiser. Co-host of @northsouthaudio & @laravelnews. @thenpingme co-founder. Opinions are mine.
Laravel 11, Flat Camps, and enriching queries
Broadcast by