Level Up Your Web Dev Game: Laravel 11 is Coming! ️ Get ready, Laravel fans! The most anticipated update of the year is almost here. Laravel 11 is landing on February 6th, 2024, bringing a slew of game-changing features that will supercharge your web development workflow. Why the buzz? Powerful new tools: Jetstream leaps forward, Sanctum gets even stronger, and artisan commands get a major overhaul. Build apps faster & smoother: Route caching, event broadcasting, and Blade improvements take performance to the next level. ⚡ Stay secure and stable: Laravel 11 comes with two years of updates, ensuring your projects are rock-solid. ️ Level up your skills: Master the latest features and impress your clients with cutting-edge code. But wait, there's more! Sneak peek with Taylor Otwell: Get a taste of the future with the mastermind behind Laravel himself! Upgrade at your own pace: No need to rush! Laravel 10 has your back with support until August 2024. Join the community: Dive into the Laravel hype, learn from other developers, and share your insights. Don't miss out! This is your chance to unlock the full potential of Laravel and take your web development skills to the stratosphere. Here's how to stay ahead of the curve: Dive deep into the new features: Explore in-depth articles and tutorials to master the latest updates. Get your upgrade guide ready: Plan your transition to Laravel 11 smoothly and efficiently. ️ Connect with the Laravel community: Learn from the best and share your excitement on social media. Middleware Reorganization: Easier Organization for More Control In Laravel 11, the familiar middleware directory in App\Http is gone when you install it. But don’t worry, creating a middleware is still a piece of cake. Just use the artisan command, and it will set everything up for your middleware. HTTP Kernel Simplified: Streamlined Routing for Faster Development Laravel 11 waves goodbye to the Kernel.php file in App\Http, shifting the responsibility for defining new middleware to the app.php file in the bootstrap folder. It’s a significant change signaling Laravel’s adaptability. // To register custom Middleware <?php use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use App\Http\Middleware\CustomMiddleware; return Application::configure() ->withProviders() ->withRouting( web: __DIR__ . '/../routes/web.php', // api: __DIR__ . '/../routes/apiphp', commands: __DIR__ . '/../routes/console.php' ) ->withMiddleware( function( Middleware $middleware ) { // $middleware->web( append: CustomMiddleware::class ); }) ->withExceptions( function( Exceptions $exceptions ){ // })->create(); Config Files Restructured: Cleaner Configuration and More Power The ‘config’ directory gets a makeover in Laravel 11. It now starts empty, with configuration variables finding a new home in the .env file, streamlining configuration management, and enhancing security. One-Click Config Magic: "config:publish" Makes Setup a Breeze A powerful addition to Laravel’s toolkit, ‘config:publish’ simplifies publishing configuration files. For instance, running ‘artisan config:publish database‘ generates a dedicated database configuration file. Precision and organization at your fingertips. // To publish all the config files php artisan config:publish // Specific config file php artisan config:publish database Routes Redefined: "install:API" Simplifies API Building Laravel 11 leaps routes by removing the api.php file from the routes directory. To create APIs, the ‘artisan install:api’ command is your new best friend, aligning with Laravel’s commitment to simplicity. php artisan install:api No-Stress Broadcasting: "install:broadcasting" Gets You Connected Fast For apps using broadcast routes or Laravel Echo, Laravel 11 streamlines the process by removing ‘channels.php’ and introducing the ‘artisan install:broadcasting’ command. Real-time communication is easy. php artisan install:broadcasting Console Kernel Says Goodbye: Say Hello to Streamlined Commands Laravel 11 says "bye-bye" to console clutter! Scheduled commands get a cozy new hangout in the console.php file, making your codebase cleaner and more adaptable. ✨ Schedule::command('reminder')->hourly() No More Command Registration Hassle: Enjoy Effortless Command Setup Forget command registration! Laravel 11's got your back. Simply create your custom commands, and they'll be automatically discovered and ready to wield with the app: prefix. php artisan make:command TestCommand // We don't need to register this command // To use php artisan app:test-command Laravel 11: Streamlined, Simplified, and More Powerful Than Ever The Laravel community, in collaboration with the Laravel Team, actively implements groundbreaking changes. Anticipate the official release of exciting innovations in web application development. Laravel remains the top choice, ushering in a new era of efficient and organized web development. Stay tuned for surprises
Streamlined Directory Structure So far, these are just a beta preview. They might change, but as of now, here is what to expect... Controllers no longer extend anything by default. No more middleware directory. Currently, Laravel includes nine middleware and many you would never customize. However, if you do want to customize them, that is moved to the App/ServiceProvider. For example: public function boot(): void { EncryptCookies::except(['some_cookie']); } No more Http/Kernel Most of the things you used to could do in the Kernel you can now do in the Bootstrap/App. return Application::configure() ->withProviders () -›withRouting( web: __DIR__.'/../routes/web.php' commands: __DIR__.'/../routes/console.php', ) ->withMiddleware(function(Middleware Smiddleware) { $middleware->web(append: LaraconMiddleware::class): }) Model casts changes Model casts are now defined as a method instead of a property. When defined as a method we can do other things, like call other methods directly from the casts. Here is an example using a new Laravel 11AsEnumCollection: protected function casts(): array { return [ 'email_verified_at' => 'datetime', 'password' => 'hashed', 'options'=› AsEnumCollection::of(UserOption::class), ]; } PHP 8.2 minimum support This was an early decision, but Laravel 11 apps require a minimum of PHP 8.2. If you are running an older version of PHP, now is a good time to get that upgraded. Install Laravel 11 Laravel 11 isn't released yet, but you can start using it and testing it by running Laravel new with the --dev flag: laravel new projectname --dev Source: https://laravel-news.com/