1. Laravel Jetstream
Laravel Jetstream is a new application scaffolding package that provides a starting point for modern applications with features like authentication, two-factor authentication, profile management, and API support.
# Install Laravel Jetstream using composer composer require laravel/jetstream # Generate the Jetstream scaffolding php artisan jetstream:install livewire # Run migrations to create the necessary tables php artisan migrate
2. Laravel Breeze
Laravel Breeze is a lightweight, minimalistic authentication scaffolding package built on top of Laravel Jetstream.
bashCopy code # Install Laravel Breeze using composer composer require laravel/breeze --dev # Generate the authentication scaffolding php artisan breeze:install # Run migrations to create the necessary tables php artisan migrate
3. Laravel Fortify
Laravel Fortify is a flexible, feature-rich authentication solution that provides the foundation for Laravel Jetstream and can be used standalone.
bashCopy code # Install Laravel Fortify using composer composer require laravel/fortify # Generate the Fortify scaffolding php artisan fortify:install # Run migrations to create the necessary tables php artisan migrate
4. Improved Routing Speed
The routing system in Laravel 8 has been improved for faster routing performance.
phpCopy code // Define your routes as usual Route::get('/hello', function () { return 'Hello, world!'; });
5. Maintenance Mode
Laravel 8 introduces a new maintenance mode that allows you to easily put your application into maintenance mode for updates and maintenance.
bashCopy code # Enable maintenance mode php artisan down # Disable maintenance mode php artisan up
6. Laravel Telescope Improvements
Laravel Telescope has been improved with new features such as the ability to monitor queued jobs and schedule tasks.
bashCopy code # Install Laravel Telescope using composer composer require laravel/telescope --dev # Publish the Telescope assets php artisan telescope:install # Run migrations to create the necessary tables php artisan migrate
7. Time Testing Helpers
Laravel 8 includes new time testing helpers to make it easier to test your code that involves dates and times.
phpCopy code // Use the time testing helpers in your tests use Illuminate\Support\Facades\Date; public function testExample() { // Freeze time to a specific date and time Date::setTestNow('2022-01-01 00:00:00'); // Assert that the current time matches the frozen time $this->assertEquals('2022-01-01 00:00:00', now()->format('Y-m-d H:i:s')); }
8. Improved Rate Limiting
Rate limiting in Laravel 8 has been improved with new features such as the ability to define rate limiters for different routes and the ability to customize the response returned when a rate limit is exceeded.
// Define rate limiters in your routes/web.php file use Illuminate\Cache\RateLimiting\Limit; use Illuminate\Http\Request; use Illuminate\Support\Facades\Route; Route::middleware('throttle:api')->group(function () { Route::get('/api/users', function (Request $request) { // }); }); // Customize the response returned when a rate limit is exceeded use Illuminate\Http\Response; use Illuminate\Support\Facades\RateLimiter; RateLimiter::for('api', function (Request $request) { return Limit::perMinute(10)->response(function (){ return response()->json(['message' => 'Too many requests'], Response::HTTP_TOO_MANY_REQUESTS);});
9. Blade Component Tags
<!-- Define a component using the new x- syntax --> <x-alert type="success"> Your account has been created. </x-alert> <!-- Use the component in your Blade templates --> <div> <x-alert type="success"> Your account has been created. </x-alert> </div>
10. Blade View Components
Laravel 8 also introduces Blade view components, which allow you to encapsulate complex UI logic in a reusable component.
// Define a view component in a PHP class namespace App\View\Components; use Illuminate\View\Component; class Alert extends Component { public $type; public $message; public function __construct($type, $message) { $this->type = $type; $this->message = $message; } public function render() { return view('components.alert'); } } // Use the view component in your Blade templates <div> <x-alert type="success" message="Your account has been created." /> </div>