Hi All,

In this tutorial, i will show you what’s new in laravel 8 version. i will give you point wise laravel 8 new features and explain it how you can use it and what’s remove in laravel 8.

8th September Laravel 8 will launch, Taylor Otwell announce in laravel website. so we are waiting for laravel 8 with new amazing feature. i read laravel website and upgrade guide and i found out some interesting new feature that love it.

So, here i will show you one by one some great features are coming in laravel 8 application. they added more enhancements on models, .env, rate limiting, route caching, factory, controller namespace etc.

Let’s see one by one in details as i can help you more.

*) Default app/Models Directory for Model

Taylor Otwell tweet and announce to next laravel 8 version will have new directory “Models” for all Eloquent Model and i love this feature.

Currently all models are be default store in app folder like app/User.php, app/Post.php etc. but laravel 8 provide new directory “Models” to store all model on that folder so it will looks like as bellow:

If you run this command “php artisan make:model Post” then it will store as like bellow:

Old Model Path:

app/User.php
app/Post.php

New Model Path:

app/Models/User.php
app/Models/Post.php

If you also want to keep model on app folder then you can remove “Models” folder and run artisan command to create model it will create model in app folder.

*) Enhancements on php artisan serve

This feature also announce via tweet and i can show you what is benefit of this feature. when you working locally. you already run provide via bellow command:

php artisan serve

and you need to change some variable value in .env file, then you have to restart again your serve command now. but laravel 8 provide way that you can not need to restart again serve command. variable value will reflect automatically.

So, also love this feature because we don’t need to restart again and again when we change .env file values.

*) Removed Controllers Namespace Prefix

Laravel 8 removed $namespace variable prefix from RouteServiceProvider.php file from previous version of laravel. so basically it will automatically apply “App\Http\Controllers” namespace to controller.

you can see old RouteServiceProvider.php and new RouteServiceProvider.php file.

Old RouteServiceProvider.php:

<?php

namespace App\Providers;

use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * This namespace is applied to your controller routes.
     *
     * In addition, it is set as the URL generator's root namespace.
     *
     * @var string
     */
    protected $namespace = 'App\Http\Controllers';

    /**
     * The path to the "home" route for your application.
     *
     * @var string
     */
    public const HOME = '/home';
....

New RouteServiceProvider.php:

<?php

namespace App\Providers;

use Illuminate\Cache\RateLimiting\Limit;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
    /**
     * The path to the "home" route for your application.
     *
     * This is used by Laravel authentication to redirect users after login.
     *
     * @var string
     */
    public const HOME = '/home';

    /**
     * Define your route model bindings, pattern filters, etc.
     *
     * @return void
     */
    public function boot()
    {
        $this->configureRateLimiting();

        $this->routes(function () {
            Route::middleware('web')
                ->group(base_path('routes/web.php'));

            Route::prefix('api')
                ->middleware('api')
                ->group(base_path('routes/api.php'));
        });
    }

....

#laravel #web-development #php

What's New in Laravel 8 | Laravel 8 New Features
14.50 GEEK