در حال بارگذاری ...

Upgrade Dependencies to 5.60:00

Now, before we review some new features in Laravel 5.6, for this series, I thought I'd start out by upgrading an actual application, the Laracasts codebase, from version 5.5 to 5.6. Okay, let's open this in Sublime and get started. Now, we're going to do this together, one by one. So let's see. Update your Laravel framework dependency to 5.6, yep, standard. So we'll go to composer.json and now bump this up. What else? We also need to bump Chris Fidel's proxy package, do I have that here?

What else? We also need to bump ChrisFidel's proxy package, do I have that here? Yep, that needs to be bumped to version 4.0. Next, if we're using any of these packages, they should be bumped. In this particular case, I'm not using any of those. What else? phpunit should be bumped to version 7. All right. So I think that should do it for dependencies. So I'm going to do a composer update.

Resolve Composer Conflicts0:55

So I think that should do it for dependencies. So I'm going to do a composer update. Ah, but now, yeah, it looks like we have some issues here. So composer's trying to resolve which versions it can safely pull in. But it looks like, yeah, we have some issues that we'll need to address. So it looks like we may have a hiccup with this package. Let's do a search for that, see if there's a recent version. We'll go to releases. Okay, so at the moment, what do we have again? DebugBar.

Remove Optimize Command1:45

That should be fine. Okay, so one more time, let's give this a run. All right. So now everything did install, it seems. We've updated the log file. But now you'll see command optimize is not defined. And that's because, if we search for that, the optimize command has been removed. So that would make sense. Which means if I go back to Sublime and we look for optimize, we can get rid of that entirely.

Which means if I go back to Sublime and we look for optimize, we can get rid of that entirely. And now if you're confused by that, notice right here, with recent improvements to PHP itself, including the OPCache, the optimize command no longer provides any relevant performance benefit. So that's the reason for it. Okay, so is that all occurrences? It is. So now, if we do a php artisan -v, we are running 5.6. But that doesn't mean the application is working yet.

So now, if we do a php artisan -v, we are running 5.6. But that doesn't mean the application is working yet. It just means it's running on 5.6 code. So if we run it, yep, everything immediately blows up. We see some references to trusted proxies. What's going on? Let's go back to the upgrade guide. Okay. So let's see. The array_wrap method.

Apply Upgrade Guide Changes2:47

So let's see. The array_wrap method. Yeah, many times when you're updating your code, certain things will be applicable and other things will not. In this case, I don't use that method. optimize we discussed that. HTML entity coding. So Laravel 5.6 now uses double encoding, and it does that to bring its feature set in alignment with HTML special chars. You'll even notice a benefit if you're passing server-side echoed code to your JavaScript.

with HTML special chars. You'll even notice a benefit if you're passing server-side echoed code to your JavaScript. Sometimes things like a quote can completely blow up your JavaScript, so that's something to think about. Anyways, if you want to return what you had before, you can add this method to your ServiceProvider. In my case, I'm good with it. What else? The rateLimiter tooManyAttempts method. Not applicable to me.

The rate limiter tooManyAttempts method. Not applicable to me. Next, if you're using the morphs method in one of your migrations, you may receive an error when attempting to run the migrations down method. Okay, we need to take a look at that. So here in my database folder, let me search for morphs. Okay, it looks like we're safe in that case. Next, there's a new method on the migration repository interface. That's okay. Eloquent, the getDateFormat method is now public.

That's okay. Eloquent, the getDateFormat method is now public. All right, these are all just little things that won't even affect your code. Hashing. So there's a new configuration file. However, if we open up config, we don't see anything there. So it looks like we will need to grab this. So let's get the raw contents and create config/hashing.php, and we'll paste that in. Okay, most likely you'll want to maintain bcrypt as your default, however, argon is also supported.

Okay, most likely you'll want to maintain bcrypt as your default, however, argon is also supported. And you'll see that's specified here. All right, let's continue on. Once again, we have a reference to double encoding, this time as it relates to the e helper. It looks like if you want to turn that off on a per case basis, you can add a second argument of false to the e function. Okay, looks like we have a new configuration file for logging. That's one of the new features we'll talk about in 5.6. So let's go ahead and grab this.

That's one of the new features we'll talk about in 5.6. So let's go ahead and grab this. And once again, config, logging.php, and I'll paste that in there. Next, it looks like the log and log level keys within config/app.php can be removed. So we'll say, let's look for log. Here we go. Let's grab those. And then log level, and it looks like it was never here. Maybe I never added that item with a recent update, so we're good to go there. Next, configure monolog using, I was never using that method, so that's not applicable.

Maybe I never added that item with a recent update, so we're good to go there. Next, configure monolog using, I was never using that method, so that's not applicable. The log writer class has been renamed to logger. If you are explicitly type hinting that, you would need to update it. In my case, I'm not using it there. And the same is true here. All right, what else? With SwiftMessage, I don't use that. I don't use bootstrap for pagination. Yeah, for your own projects, some of these will be applicable, and once again, some will

I don't use Bootstrap for pagination. Yeah, for your own projects, some of these will be applicable, and once again, some will not. Let's see, routing. So when returning a newly created Eloquent model directly from a route, yeah. So now, before in Laravel 5.5 and below, if you just, for example, in your route, you return new Post, right? That would before return a 200 status code, which isn't quite right. So now it returns a 201 created. Okay, let's see, because it looks like this maybe relates to the issue before.

Fix Trusted Proxies Middleware5:55

So now it returns a 201 created. Okay, let's see, because it looks like this maybe relates to the issue before. So if we go to laracast.test, it did seem like there was something related to trusted proxies. Slight changes need to be made to the TrustProxies middleware. So let's open that, and let's see what. The headers property, which was previously an array, is now a bit property that accepts several different values. For example, to trust all forward headers, you may update your headers property to the following value.

For example, to trust all forward headers, you may update your headers property to the following value. Okay, so we're going to use that. And let's see, let's come back to Chrome, give that a refresh, and there we go. The page is now loading. Next, anything else? Two more things. So it looks like a method on this interface has been renamed, okay? I'm not using it. We also encourage you to view the changes in the Laravel, Laravel GitHub repository.

Update Testing Package Versions7:32

So immediately I know, all right, it might look good in the browser. It may seem like things are working, but at some point a test is failing, so I cannot deploy this. So it looks like we have an issue with, hmm, BrowserKitTesting page constraint must be compatible. So there's an interface issue there. So one thing we're using, if I go back to composer.json, is I still depend upon the older BrowserKitTesting layout for some of my tests. This was in an earlier version of Laravel, and then it was extracted to its own package. So let's see if we need to give that a bump.

This was in an earlier version of Laravel, and then it was extracted to its own package. So let's see if we need to give that a bump. You can do this through the command line, but I often just check for the releases. Okay, so it looks like it is up to version 4. So let's give that a bump, and once again do a composer update. All right, and we have bumped that up. So let's give that another run. Ah, okay, great. So that does return green, which means it was just a version compatibility issue. So great.

So that does return green, which means it was just a version compatibility issue. So great. And then let's also do unit. Those are green as well. So we seem to be in the clear, which means in the next episode, let's begin discussing what's new in version 5.6.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟