Laravel 11 Overview0:00
Well, can you believe it, we are already on Laravel 11. Time goes so fast. And no doubt you're wondering, what's new? What should I be aware of when I upgrade my existing Laravel 10 app to use Laravel 11? In this quickfire series, I'm going to make you aware of as many of those features as possible so that you can get right back to work and stay productive. Let's dive in. One key theme in Laravel 11 is slimming down the application structure. Here in this Laravel 10 application, you'll see the very familiar list of config files that we've had in pretty much every single project for years now, but it's been slimmed
Slimmer Config Structure0:37
Here in this Laravel 10 application, you'll see the very familiar list of config files that we've had in pretty much every single project for years now, but it's been slimmed down in Laravel 11. Here in this Laravel 11 application, you'll note that, for example, Sanctum.php is missing, Windows.php is missing, Vue.php is missing. It's not that these files are no longer supported or important in Laravel, it's just that it's very rare for us as developers to have to change these config files. So they've been pulled down into the framework, and at any point we can bring them back to make changes as and when required. Let me show you how.
Publishing Config Files1:15
make changes as and when required. Let me show you how. From the terminal, you can type php artisan config:publish, which will show a list of all of the config files that are available to publish into your application. Let's go down to Vue. Imagine, for example, that we want to change the directory where Blade views are stored in our Laravel app. I'll hit enter. It publishes the Vue configuration file, and you'll see that that has appeared in my config file inside my Laravel 11 project.
Service Provider Registration1:39
It publishes the Vue configuration file, and you'll see that that has appeared in my config file inside my Laravel 11 project. Opening it up, well, the contents will be very familiar to you. Everything's changed in how you use config files, so perhaps under here we want another directory, more views that we add, and everything will work exactly as expected. Another key change in Laravel 11 when it comes to the config is with how service providers are registered. In this Laravel 10 application, app.php has a providers key, no doubt you're familiar with it, and here we can register any service provider that we want to. However, if we switch over to this Laravel 11 project, app.php has no providers key,
with it, and here we can register any service provider that we want to. However, if we switch over to this Laravel 11 project, app.php has no providers key, so how do we register custom service providers? Well, let's test it out. We'll go to the terminal, and why don't we make our own provider. We'll call it the TestingServiceProvider. Let's open it up, and in the register method, how about we dump and die, and just say, here I am. So, if we execute anything that goes through the application, for example, php artisan inspire, you would expect it to hit this line and dump die, here I am, to the console.
So, if we execute anything that goes through the application, for example, php artisan inspire, you would expect it to hit this line and dump die, here I am, to the console. And there we go. Note that we never registered this provider manually. Laravel now does that for you. If you create a provider from the terminal using php artisan make:provider, you don't have to register it at all. But if you're creating your providers manually, how do you register them? All providers are now registered under bootstrap/providers.php, where you'll find this simple array of fully qualified class names that correlate to the different service providers.
All providers are now registered under bootstrap/providers.php, where you'll find this simple array of fully qualified class names that correlate to the different service providers in the app. So if I comment out this TestingServiceProvider, which was added by the php artisan command, and then I rerun the php artisan inspire command, note that we see no dd output. So that's a change to keep in mind. You don't register providers inside the config, you register them inside bootstrap/providers.php.
