Live Stream - Testing the Laravel 10.x Shift

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right hey everybody thanks for joining me live especially if you are in Portugal for laricon EU um my focus looks off let's see if we can fix that nope maybe who knows anyway uh yeah so today I wanted to take the opportunity kind of for myself to um attempt to run the laravel 10 shift this is something I've been working on for probably the past week and a half I've been prepping it for since the beginning of the year really but but really deep in the code uh in the last week or so um so yeah so first run ever uh well that's a bit of a lie uh this will be the second run ever I ran it earlier just to make sure that it actually would run in an effort to not waste a whole lot of stream time so it does actually run on the server now whether or not it does what we want that's the part I want to look at uh today so for those that haven't maybe seen a previous stream uh you know I don't necessarily get into the the shift code um too often there are definitely some streams about it but it you know it's infrequent compared to some of the other stuff like packages or um you know pring things to laravel itself so um there's there's some pieces in here uh basically the way any Shift Works is it's kind of like the old school chain of responsibility kind of thing um or you can even think of it like a collection pipeline for you know being familiar with laravel there's basically this set of tasks that every shift has and it's just a a you know set of these these uh classes that follow a real simple and simple interface of um you know being a task which just has a perform you perform that task and then it potentially has a commit that it makes and it's super straightforward and and each shift has you know 30 40 50 of these individual tasks so just get a feel for the laravel 10 shift kind of from a code from a really low level perspective um you know it formats the code it does short array syntax it checks class properties optional parameter orders all these different tasks you know some are laravel but some are PHP specific as well for example optional parameter order matters if you have an optional parameter that starts to matter more in laravel8 if it comes before a a required parameter that's that's no longer kind of juggled um by PHP there's also some layer belt 10 specific things like updating the core files but there's other tasks too that maybe get shared for example a lot of tasks are out of the shift workbench now that's just kind of a place where you can run these tasks individually for example converting optionals laravel optionals helper to null safe things again now that are in php8 so Faker methods so there are some things even that are from previous shifts that maybe used to be optional changes but now are required because you know maybe they were deprecated and now removed so those are some really good examples of some some things you'll see in here so this is kind of just a you know a highlight but there's probably what line 73 starts at 44 so roughly 30 tasks so far uh individual bits of automation that happen to make sure that you're upgraded to laravel 10 and have an application that looks as if you ran you know laravel new one slerevel10 was released so that's pretty cool so what I want to do right now though is kind of run this against the laravel shift.com website which is a laravel application and kind of see what comes out uh the other side so I'm going to actually swap over to my MacBook here just because there's some SSH stuff and some keys so let me fire this up we're going to watch the logs and if you're not familiar with the shift logs I gave a whole talk about them at laricon like 2018 a long time ago it's called laravel by the numbers you can check it out it's on YouTube um but what I'll do is I'll start running this from my terminal on my MacBook Pro and we should start seeing uh that log file that I talk about in that presentation start getting output here so let's just tail that again like I said I did do a run before so there's this run so we should see that get truncated it just gives us some shift version information a unique ID for this particular run that's again all for logging and everything you see here now is is kind of more analytical information allows me to improve shift but we'll kind of watch this um and see those tasks that I was talking about completed with a little bit of a time stamp again just some analytical information so one of the things that uh it's doing now of course is is formatting that's that code format task so it took about 20 seconds it's doing the shorter rate task now so we're just gonna let this burn through here and we'll see um kind of how how it all looks in the pr there should be a lot of stuff um this is actually a really it's a pretty simple upgrade as far as the actual code changes um into the core files but it's actually a it's a really really tedious upgrade if you want to follow all of laravel's conventions because laravel has now adopted types in laravel 10 so there's a lot of type hints not only in parameters that were added to the skeleton code but but mostly to the return types in all of the skeleton codes so you know controllers requests migration the service providers uh factories just everything that comes out of the box with our valve now has some typing around it um so to add all those and put those all in your code again if you if you want to kind of follow the latest conventions which is which is what uh it's all about um you know shift needs to be able to do that for you again to make your application look as if it were always running laravel 10 so um so that's going to be a lot of changes so I kind of want to see what that looks like in action here and then we'll we'll kind of take a nitpick through the pr and if I have time I'll maybe make some live fixes but if not again just kind of a sneak peek at the laravel 10 shift again first kind of first actual run first project uh here against it so looks like I have some parse errors um this is actually so shift some of the tasks I'll actually use nikkik parser to analyze the code and [Music] apparently I've got a file in my project that has a syntax error so I'll have to dig that up on my own um it seems to be the same one repeating over and over and over again so not a huge deal there but probably something I want to look at so we see that that typing and that parsing actually was was was kind of intensive so we went from 70 seconds to about 140 seconds so a bulk again a bulk of that work even for a computer uh took you know took a minute literally a minute to to do all that so imagine doing all that by hand if it if it took the computer with a massive CPU to uh to do all that so okay cool so just like any other shift we we get um a PR so let's go check that out okay so 11 commits 380 files changed to see again that's massive and I guarantee you that's all around uh the typing so let's take a let's take a peek at this again kind of from a from a user perspective but again um kind of me as a Creator perspective did I get everything in here right you know does this make sense okay so includes the changes for upgrading to larabelle 10 great um committed to the test branch of course all this is pretty boilerplate so I feel like that's good I just want to make sure this says laravel 10. okay so we shift core files we converted optional to null safe we did those fact Faker methods we converted dates to uh property cast so again this was this was one of the um old deprecations dates has been deprecated for a while now but it was finally removed the model property dates so you should use cast instead so that was automated for me all the config files those are always annoying because they're constantly changing new options being added or or updated or new EnV variables okay so we bumped the laravel dependencies we're going to look at the actual code here in a second I just want to kind of fine-tooth the the pr first okay so here's that typing so we add PHP types to core methods so that's the laravel stuff then we add PHP type hints technically we're adding the PHP type hints from Doc blocks so I should I should probably make that more clear like where did we get these tie pins right these are the ones that came from the doc blocks so again I'll look at the code here in a second and then we remove redundant types in Doc blocks great okay shift could not upgrade that version 10. let's make sure this link looks good yes it does shift upgraded your config file actually you know what this link is dead so that's one thing I need to fix so I'm just going to take some screenshots here this kind of is my quick way to add a quote unquote ticket uh for me to kind of fix something okay shift did the true customizations good shift updated your dependencies for laravel 10 good laravel 10. so again just making sure that the a lot of these um are templates but I need to make sure that the kind of the variables swap out so this doesn't say laravel 9 for example okay so these are the these are the things that jumped major versions and and you know as such you might want to go check them out so they should all be clickable to packages great and from there you can kind of look at the upgrade guide all right and that's the link to the laravel 10 repo so that's broken got a screenshot of that so that looks good the laravel 10 added PHP types to all userland code included in a new laravel application in an effort to modernize your code shift added types to any method used by layerval within your application to any method used by laravel does that make sense shift added types to any method used by laravel I don't know if I like the word used by laravel it's like included I kind of use the word included here these are those little nuances but but they matter because it you know you want to relay the right information about what that means okay anyway let's let's take a look because this is the massive one and we can see from the scroll bar here uh yeah this is massive so this is where bulk of the file changes happen so again we see 380 files changed a lot of them are here and again you can tell from this tiny little scroll bar but what this is doing is adding all of the types or return types um two methods again that are part of laravel's kind of skeleton application so for example commands are something laravel has and generates as part of your application the handle method now is void or returns void by default so that's what it's adding here all these different pieces so yeah again every command I've got tons of commands because that's how I manage the application if we get into all the controllers we notice now that you know index's response stores redirect update so yeah we're gonna have all the controllers now have type pins uh for returns possibly even parameters depending so yeah all of my controllers if we go down all the requests so we got rules this array messages and array yeah I mean this is awesome again if you if you wanted to adopt this convention and you were to do this by hand I mean imagine how long this would take you I mean shift isn't even a huge application I mean it it's probably a medium-sized application but man look at this I mean this the scrolling I'm going quick and the scrolling is endless all the migrations so up and down are all void crazy Cedars yeah so everywhere shift kind of figures out and runs those uh even in the tests right your test cases or void they don't they don't return anything so again a lot of the file changes are in this particular command it seems to be seems to be good though um all right cool now with type bits and your code defining types within PHP doc blocks is redundant the flareval has removed all of them at param and at return tags from Doc blocks for methods which now have types which now have types maybe I should say something like can I edit those see I can which are now typed with PHP maybe something like that I don't know which are now typed with PHP which are now typed by PHP I don't know similarly shift removed these tags from any doc block where the method has equivalent type hints however if you wish to preserve your full dock block you may undo this commit by running this specific command awesome okay so let's kind of take a look at this one I actually removed a lot of the dock blocks in my code already um I've never been a big fan of Doc blocks at least not from the typing perspective so a lot of these are just default things that are left over so but we see here that okay schedule schedule void void all that's been typed now in those previous commits so it's removed that so that's kind of what this particular task does so even in something core like the Handler throwable throwable returns void void it's already removed so all the service providers yeah so anywhere it matches up and it's been defined in PHP it's removed it so pretty straightforward commit there I think looks good though I would expect it to get a lot more in most applications but again I I've I've run some workbench tasks where I've just blanketly removed entire doc blocks from my code base level 10 now has a dependency for monologue 3.x shift detected references to monologue within your application it did is that true let's see if that's true larval shift do I have monologue in my application code let's find this monologue oh you know what it is I bet you it's I bet you it's a config file not twig what the heck yeah it's the login config file hmm it would be nice if it would be nice maybe if I ignored if I ignored the config logging file or I gave it a pass right that would be nice it'd probably be smart to do that you're not really using it in code if it's just a reference in the logging file what this really matters is if you were you know if you were like newing up a something somewhere you know that would be bad so yeah I think what I could do is probably just say if that's if that's in the config logging file ignore it so we could do that okay next one all of the underlying Symphony components have been upgraded shift detected references is that true as well Symphony let's just make a little use Symphony oh I do of course I do yeah I've got processes enamel for the workbench yeah okay so that's that's legit that's that's legit all right Lambo began using Veet I'm using V yeah I've got feet okay so this this probably shouldn't happen if you're using Veet you don't need to talk about that so let's let's just pretend that didn't happen uh and let's pretend this one didn't happen right okay shift detected you're using Horizon or Nova I am and be sure to run view cash clear great and then congratulations you're on the latest version awesome of course my tests failed because laravel 10 is not actually released yet okay good that was actually that was actually pretty good called by laravel oh yeah uh let's let's see how that fits here any methods used by lairfel with okay so in an effort to monetize your code shift added types to any method called by Lair Vel within your application yeah I like called I like called better yeah let's change it it's better than used it's more it's more code-esque you know it's not super technical like invoked but let's get that oh all right let me just do my little screenshot fix okay let's let's fix a few of these and then I'll probably cut it short um let's Okay so we had that monologue one and Veet I think we can I think we can fix those two let's go fix that all right let's close this go back to shift and let's get into one of those was monologue I think these are all under miscellaneous yeah here we go okay so monologue empty paths I think what we could do is we could just straight we could just straight array diff whatever it finds against config logging dot PHP I think that would be the simplest thing to do so let's do that so whatever you find and then and then basically diff out uh config logging and if you're empty at that point then don't leave this message because the logging file it's going to get upgraded um by shift automatically so again if there were any references in there that were bad um that's going to get caught by a different task anyway okay and then actually coincidentally in the same miscellaneous is Veet so basically we would want to say if shift file exists what was That V Dot config.js is that right basically return right so if if you have a Veet configuration file there's there's no reason to tell you about V right just reduce a little bit of that noise um is that correct I think it's feet.config.js oh sorry I thought Izzy was awake but she's got beat.config.js all good okay let's um let's Commit This and we'll rerun it right let's just kind of see if our work looked good uh so let's do it get status get a dash P so we'll diff that against the logging file great and if you have a veed config file then of course we're not going to leave that comment good good commit Dash and tweaks from live stream get push origin head all right well let's go out actually and we need to close let's just close this PR to avoid any confusion and we'll rerun it so let me jump back to the um MacBook Pro here and let's see if we can fix this and run it again so get get the laravel 10 today I pulled that up yeah okay all right let's get our SSH worker 02 worker OT is like my straw worker you know secondary worker it's kind of what I just test things out on um so let's do far what was that tail Dash F far uh log shift test yeah there it is all right and let's all right we should be re-running now yep there we go okay so it's pulling in some new stuff we got a new version of shift from the deployment and it's going to format with pint yeah okay so we saw this before let's make sure I close that I did good all right so let's let this get running so we saw last time it took about two minutes because there was a massive amount of tie pins that it added so we'll give this a second what do we think audience who's out here Daniel Fabian what do y'all think laravel 10 shift looks good ship it ready to go okay yeah so most of these tasks actually are pretty quick taking less than a second but yeah those those typing ones because it parses every file in the application multiple times it's uh they take a second all right so we got Anonymous migrations I might make a note about removing all of those doc blocks two just kind of thinking about that out loud all right speaking of which we we saw all this run so unless it fails let's go to desktop called okay yeah we could fix these in the background while we're waiting let's do that um so what was that it was like used by laravel where was that what was this called used by laravel within your application used by laravel Within there we go okay so we'll do this called I like that better okay so that fixes that okay we fixed this hopefully which are now typed with PHP which are now typed with PHP let's revisit this which are now typed oh I changed it um which are now now there's gonna be a lot of those crap doc blocks for methods all right dock blocks for methods which come on well oh capital B I think there we go all right laravel has removed all of the params from for methods which now have types now with typins in your code defining types within PHP dot blocks is redundant larval has removed all of the which which are now typed with PHP Maybe I think this similarly doesn't really flow well shift removed these tags from any Top Line okay I think that part's good okay and then yes I need to create the repo we'll get back to that I could do that off stream that's not very exciting okay let's see if our comments minus the ones I just tweaked um are better so if we scroll down here again we're gonna we just fixed that and we just fixed this okay that um monologue thing was between these two before the symphony one and it is no longer there great so our our patch worked and similarly um the Veet conversion was was in here as well and and now it's it's not here so good so we fixed we fixed those two things so I think that I think honestly the main thing left is going to be to create this link you know I can fix that again off stream I just gotta go build the repo and push up some sample files um I think the only other thing I noticed was that this is still laravel it pulls the latest version of laravel which is technically 948 because 10 has not been released yet so I just need to hard code um you know carrot 10.0 there so or well technically I need to hard code like 10 dot x dash Dev or whatever the you know that way when I release this a beta version of this next week you would actually be able to download and run run composer update so I'm going to tweak that um next so let's just do my little handy screenshot there so we'll tweak that and let's see what's going on in the comments um is there anything else major about 10 or did they just bump the major version because of the breaking type change there are deprecations um again that dates thing is one of them it it's not you know again it doesn't seem like a lot but if you were still um doing that there's a fair number of deprecations um the upgrade guide is it's incomplete but um it does give you an idea of some of the big changes um there are a lot of deprecations that have been floating around in laravel because of LTS they didn't get rid of them but now that LTS is gone um you know they can safely be removed finally so the dates property is one of them uh query based is another one the dispatch now methods there's a lot of deprecations so far that are documented redirect home um so these are all things that shift would find and replace for you um but as far as like Paradigm shifts like um Paradigm changes like short of the typing I can't think of anything off the top of my head that I've seen uh you know that that's there so so yeah if you if you don't have any of these deprecated things that you're doing and you and you don't care about typing um and you don't override any methods uh you know you're probably okay I don't know you may have to adopt the typing because of the inherited class I remember a debate about this I'd have to test it to see if it's true or not but I'm pretty sure that when you when you inherit from a class so for example think of a laravel command you're extending a base command from laravel and that base command is going to now be typed I think if you don't have the type in yours it's I think PHP is going to complain I think I'd have to I'd have to verify that there are cases where it won't so again it just kind of depends on if it's defined in the parent class so if it is then yeah you there's a there's a crap load of changes because you got to type everything so um all right if I have uh if I have types an array slash collection doc blocks are they going to be deleted in the shift EG array int no that's a good question uh no shift will not delete um I've I've set it up to not delete any uh type hint that is more specific is what I call it so if you have a doc block with a specific type hint that is more specific than the one provided by PHP the example you've given here is in PHP all I would say is you know that collection parameter is an array or whatever but in your doc block you have array and then you actually you know type uh that it's that's a it's an integer key and it's users underneath or if you had like a string array and you use string bracket bracket in your doc block shift is smart enough not to remove those because they're more specific than what PHP is providing at this time so good question yeah I think typing is required in some cases which is why it's a yeah exactly yeah so there are probably some areas where you wouldn't have to type your code like controllers because you're not extending anything from a parent class but I think in your service providers in your commands uh in middleware where you're actually extending a base class which has a method defined that now has a type you'd have to end up typing it and that's going to be a lot of tedious changes so yeah that's probably the biggest paradigm shift laravel normally has two two-ish of those each um each release so like last time was like um class-based routing and Anonymous migrations uh so you know that's um that's something that's a paradigm shift again you don't have to adopt it all the time so I believe only user land is type hinted but the framework isn't for backwards compatibility so if one doesn't add the type hints should mostly work yeah I agree I think it should mostly work uh but I don't think it I don't think leaving out the types would work everywhere um yeah mostly exactly so okay cool well thanks everybody for joining live uh I will stream next week either more changes to this or maybe some last minute changes to laravel 10 itself I've been kind of thinking about some other things that I might want to squeak into the framework uh given the time is now for breaking changes uh so if you have any feedback on what you saw here today shoot me a um DM on Twitter or leave a message in the YouTube comments and again thanks everybody see you next time
Info
Channel: Jason McCreary
Views: 297
Rating: undefined out of 5
Keywords:
Id: pcPjiShpSBs
Channel Id: undefined
Length: 33min 41sec (2021 seconds)
Published: Wed Jan 25 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.