Shift - Upgrading to Laravel 10 with Shift

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all right I wanted to provide a fuller demo of the laravel 10 shift and normally I use it to update confident laravel.com which is one of my course sites uh I would say this is probably a medium-sized application it's not necessarily a lot of code but it does have a lot of components within laravel so it has you know commands jobs policies events some custom service classes so for those reasons again even though maybe it's not a lot of code it does touch a lot of pieces of the framework so I think it provides kind of a good use case of a real world application that probably most people running shift would see so uh yeah let's go ahead and jump out to laravelship.com we'll run the laravel 10.x shift so there it is and I'm just going to paste in the Clone URL that it says I can do and master branch is fine so let's hit check out and run and I actually have a Shifty plan of course as the creator of shift I can run any shift for free so I just get to hit run here instead of breaking out the credit card uh all right so this is queuing and running great there we go and it might take about a minute so let's go ahead and use our time wisely I'll jump out to the command line um I'm on the master Branch here but you know what I'm going to go ahead and run uh the tests these are actually written in pest so we'll kind of let those run in the background and make sure I'm still in a green State and yeah let's go over here uh to the project uh in my editor phpstorm and yeah let's go ahead and open up uh composer Json looks like I was in here a minute ago so yeah this is all older stuff laravel9 uh it's still running but um at the very least we're going to be updating uh this file so I just kind of like to open this to get a feel for like the dependencies that were in here not too many most things are first party laravel or the packages that laravel itself uses uh guzzle and so forth so good let's go see how we're doing uh that ran great all right cool so let's jump out to the shift and anytime I'm reviewing a shift uh here's here's kind of the way in which I go about it um of course I kind of get a feel for the general stats of the pr so about a hundred files changed and looks like more deletions than additions that's awesome senior senior Dev move right there from shift I took a peek at the commits I'll look at these more closely here in a minute I really like to start with the comments and this just kind of lets me know what shift did it also gives a chance for the um any you know CI to run which in this case has already failed uh so good to know that we're going to need to do some things here so maybe the comments will shed some light on what's going on with that so starting at the top here uh shift upgraded your configuration files by defaulting them and merging your true customizations all right so we should review this commit and what this is doing here is basically again it attempts to merge your uh configuration files with uh the new configuration files in the layer valve the configuration files are always changing even in minor versions uh major versions every config file is likely changed and I've just seen too many times where a single line of missing configuration can really make a developer bang their head against the wall for hours so shift takes a little bit of an opinionated approach here and kind of defaults these files and brings your changes back over so let's let's kind of take a peek here and see what that means for the most part it really just means it adds comments and new options but there are situations where it will overwrite existing options with the newer one so in this case it is adding this username but maybe I had hard set password Here and Now password got overridden with just the EnV variable and this is kind of where that opinionation uh happens or that opinionated uh approach uh is that shift wants you to use these environment variables and it does so because it makes the maintenance of these files much easier whether you use shift or not if you're using the environment variables instead of hard coding values in kind of this default argument here you can pretty much just copy in the new files at any point in time you don't have to really think about all those changes that are happening uh and and that's that's kind of my advocation uh and that's why it's also built in to how shift automates it so we can see here it's really just the addition of these new options and again you might not think it but but missing just this new Option here could actually cause an error in your application depending on you know what that option is I've definitely seen it before so that looks good there's nothing that really got overridden so I think this is safe and something else I like to do with these shift br's is if the comment's good or I've reviewed it or it doesn't really apply to me I just go ahead and remove it all right the next thing dependencies this is uh kind of the last big hurdle of shift I really try to make this something that is a lot easier whether again you use shift or not updating your dependencies is probably the biggest pain point of doing an upgrade um so what shift is doing here is it letting us know that it did bump uh the versions We can see those from the commit here in a minute but it kind of highlights the ones that it's sent across a major version and that's these four out of the dependencies that I had so what would be good is for me to probably check Dom PDF here and see you know the change log is there anything that um is notable maybe in this 2.0 version so we can take a peek at these but it seems like for the most part um kind of looking at this deprecated breaking changes HTML5 parser because it was always on orientation removed in favor of options so it seems like there's nothing here that would probably um break necessarily in 2.0 uh unless I was maybe using these options but it claims it was never used and it claims that the HTML parser was always on um so it doesn't seem like there's anything here that would probably hurt me unless maybe I have a custom configuration file so I can check for that the laravel packages I never really worry about because a lot of times those just have uh first party you know bumps uh so they they jump a major version just like laravel does um that's just kind of for organization so the last one will really just be Sentry and to see if there's any kind of opportunity um to kind of go through this uh so the change log we could check this out uh happy to announce so it looks like there's support for 10 and there's a new Option um doesn't seem like there's anything but again I should probably check that a little closer so let's keep going next comment laravel renamed the password reset stable to password reset tokens an optional change but shift found that I was using password resets and created a migration awesome so this is actually probably the change related to layer value UI and again for first party packages shift does attempt to go ahead and make those changes if it sees that you're using them so that's why I don't typically change those because here's a good example shift just automatically did what would have been needed in that change log anyway great okay laravel 10 added PHP type-ins to all user Clan code included in a new layervous application so it looks like shift automated that for me let's take a peek um cool yeah so looks like all those commands I was talking about are now void uh if we jump down to controllers this returns a view this returns a redirection awesome uh great yeah that would be that'd be a super tedious change uh to do myself uh okay so now with typins defining types with Pap doc blocks is redundant shift remove these great so yeah so the returns uh are all just gone now um yeah so void is void they're just in the code redirect response so it got rid of this generic one in the controller because there's a more specific one actually that's that's more correct so yay code comments uh Gone all right shift understands developers have different preferences when it comes to type hints uh so this can be undone effectively so again if you didn't want these types you can kind of revert these here's the exact command I could run to revert those changes all of the underlying Symphony components used by laravel have been upgraded to 6.2 shift detected references to Symphony review the change log am I doing all right let's check this uh okay good all my tests passed on Magister so let's do get fetch origin we'll do a git checkout on the shift Branch uh 8288 all right and let's jump back to the editor where am I doing anything with Symphony oh this is just the okay these are just the type hints for the middleware now okay so I'm not actually using Symphony myself okay so that that can be re that can be removed we don't need to worry about that and again I'm going to keep these types so kind of sticking with the removal of these comments okay next comment laravel began using feet to build front-end Assets in laravel 919 I can run the Veet converter for free okay I'll do that separately um again I like to stay focused on the laravel uh 10 uh shift so I'll just kind of remove that I'll do that at a separate time level 10 requires composer 2 2 or higher you can run composer version all right two five four so that's greater than 2 2 so we're good there all right let's dump that out PHP requires 8.1 or higher you should verify your version okay so I know that I'm running eight two locally and I'm running eight one on the server but I probably want to check my GitHub actions that might have been the reason why it was failing congratulations you're running the latest shift here's some other ones I can run cool okay and then final comment oh looks like there's actually a syntax error here I can check that by running PHP Dash l and let's get this what's wrong with you ah duplicate import okay that actually is a common thing sometimes especially with these um so let's open and it pulled in this contract it looks like I'm gonna cut that out to get rid of the error but where is that being used oh it's this it's this type hint that's what happened here okay so really I can kind of in line with the changes shift made I can remove that and let's just do a fully qualified reference there okay that should take care of that but keep that type in so it looks like there was just an issue with the type in so let me just go ahead and do a get at Dash p so we killed that duplicate import um I could have aliased it I guess but uh based on this fully qualified return type that's probably just what I can use anyway and again this is one of kind of laravel's class is not my own so good to probably follow suit with what they have so git commit Dash M uh let's fix PHP error all right let's go ahead and push that up again maybe that was what the check was we'll see all right let's delete that comment because I took care of that all right scrolling back up to the top here we've gone through all the comments now I just kind of like to take a look at these commits and again that you know you could look at all the file changes up here but another reason that shift makes these nice Atomic commits is because you can really just kind of jump in and see this change in isolation you're not having to look through you know 89 files so I like to kind of look at it this way um okay so remove explicit call or register policies this is something laravel 10 does automatically so shift just found this code and got rid of it for me awesome remove fruitcake uh laravel Coors dependency so yes this actually got assimilated um in laravel 9 but it was kind of a later version of laravel9 it was one of the minor releases um and again I just kind of know all this as the creator of shift but uh this is now done in the laravel 9 shift but because again maybe I ran this maybe I ran the live online shift really early and it happened later in the life cycle um the label 10 shift is is picking this up for me so that's kind of a nice thing that's pretty cool uh the rest we kind of looked at these default config files the bumping of dependencies the type pins the doc blocks and then there's that rename password reset table so that's really everything um that it did I think we're in a place now where we've kind of gone through that first pass so now what I like to do is just let's just try to run composer update right let's see if everything installs there's no errors according to you know what shift kind of gave me in its report okay but we do have some dependencies that's pretty much expected no matter what um oh yes the dreaded laravel Vimeo uh this I I groan because this laravel um or this package is always behind yeah look at this it still has the laravel 9 compatibility one that I submitted or shift submitted uh a year ago more than a year ago so it's it's submitted a layer valve ten one as well excellent yeah they just you know as a paying customer of Vimeo in fact confident laravel uses Vimeo to serve up the videos for the course like get on this you know get this merged anyway shift um shift does this is one of the things shift does for the community it goes out and and submits kind of all of these PRS um but since this hasn't been merged uh there is kind of this thing here where you can you can kind of try to use it directly so you can use shift's Fork so let's let's see if shifts forked uh works I'm pretty sure if I remember right it worked last time um so I'm just going to jump in my composer file I'm going to drop this down at the bottom and then it says update your dependency constraint for this Branch okay so let's go back up to Vimeo and there's Vimeo let's take that and let's run that composer update again fingers crossed given that that was kind of the last one in the line here I'm hoping that's my own oh hey it is it is my only incompatibility awesome so this seemed to install based on that fork it doesn't necessarily mean that that fork is a hundred percent but it does mean that it is compatible from a composer perspective and for now that's all I'm really caring about um so what do we change here let's just do a get add Dash U on those get commit Dash M I'm going to say composer update let's go ahead and push that because our GitHub action our CI is still failing so again I want to give it time to run but we know those tests were passing on Master now that we have our dependencies going let's see if they're passing locally so let's just close this and while we're waiting on that let me go out to Sentry and just kind of take a peek um at that so we know we have the requirement I just want to make sure that kind of the integration hasn't changed so let's just take this opportunity to go into my Handler and okay it looks like they are binding this differently now they're doing it in this register bit so I'm gonna take that and get rid of this and since this is just calling report I can actually get whoops get rid of that now because it's just calling the parent class so that actually helps me streamline this and let's bring in this um as well so Sentry that should be good okay so good yeah there's opportunity to refactor for Sentry there and then the last thing while I'm thinking about it with these other dependencies just to make sure they're compatible let's go see if I have that Dom PDF I don't see the Dom PDF or PDF config file in here so I'm going to assume that that's okay because it's the only thing it mentioned uh in the changelog was that those options uh were changed and because I'm not using their config it should use the default config no problem there so I think I could safely assume that the rest of these dependencies are good the password resets table is fine we're cool with all those options the last thing I think I can do here is again check GitHub actions to see if there's an opportunity to make sure I'm running 8-1 and there is okay so let's just see anywhere where I'm saying 8.0 I'm going to change that to eight one to update my build it's running past and let's go back hey and all my tests are passing okay let's get this cleaned up because I think I think I'm good to go um let's do a good at Dash p on app so again we just kind of modernized our Sentry integration which allowed us to get rid of kind of this overridden method in our Handler which we don't need anymore so that's good so let's do a git commit on that in isolation we'll just do update Sentry integration and then finally we updated our workflow uh to be 8.1 according to laravel 10's new requirements so git commit Dash M bump CI for PHP 8.1 all right get push origin head tester passing dependencies are installing uh even had a little bit of a refactor here so let's let's kill the rest of these comments I'm cool with those doc blocks uh being removed I'm cool with 8.1 now uh this migration will happen as part of my deployment so I'm good there as well uh the test ran too so there weren't any issues with that and then again I I can run all these cool things after the fact if I want um so yeah fine with me uh so CI is running looks like build failed is that true did I do something wrong oh no that was just delayed UI there all right let's give this a second to run here and see if we're getting a nice little green check box that's kind of cool thing about this automation uh it marries really nicely with shift right I think if I didn't have a test suite and I didn't have CI uh you know hey there it is green check box uh you know I'd probably want to go through these changes a little more I'd probably want to fire up the application locally and take a look at it but because I have these tools and that's what's telling me on Master even which is in production that um you know this is fine and this is running then I'm ready to go so I'm gonna squash this up and there you have it uh yeah there it is upgraded to laravel 10 even did a little bit of refactoring bumped up the CI uh and I have all those nice sweet uh uh you know tie pins in my code now so that's pretty good so next step is is deploy this to uh production and and make sure that goes smoothly
Info
Channel: Jason McCreary
Views: 367
Rating: undefined out of 5
Keywords:
Id: d0lRuRFMzAQ
Channel Id: undefined
Length: 21min 31sec (1291 seconds)
Published: Mon Feb 27 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.