CodeIn House

  • Laravel
  • WordPress
  • jQuery
  • Javascript
  • Contact
Home   Laravel   The New Coming to Laravel 5.7 Release

The New Coming to Laravel 5.7 Release

September 9, 2018 by SNK

laravel 5.7 release

In this article we are going to see what are we getting from laravel out of the box in its most recent version 5.7.

If you haven’t gone through the latest laravel documentation then you can click this link here or follow this article below.

Let’s get started

laravel have 9 major changes in this current release. We are going to mention them in points and learn more brief throughout the article.

  1. Laravel Nova
  2. Email Verification
  3. Guest User Gate / Policies
  4. Symfony Dump Server
  5. Notification Localization
  6. Console Testing
  7. URL Generator & Callable Syntax
  8. Paginator Links
  9. Filesystem Read / Write Steams

Below we are going to disucss in detail about what are the new changes and release in 5.7

So, What’s New Coming to laravel 5.7 Release ?

Laravel Nova

Laravel nova is the most beautiful and elegantly designed administration panel for laravel.  It has code driven configration and can be integrated without touching anything in your eloquent models and making changes in your current laravel application.

Nova is the sleek administration panel which is designed with the help of JavaScript framework Vue. It was previously mentioned by Taylor during the Laracon US 2018 which was back official released in August 22 2018 as Orion but later it changed to nova.

If you want to learn more about it check Laravel Nova official homepage

Email Verification

Finally its here, we know most of the websites asks for email verification after user registration to prevent unwanted signups and verify the real users email. In the past we need to create our own verification system to enable activation link to the email, but now laravel ships it out of the box.

We just need to implement MustVerifyEmail interface inside the User Model and other are handled it self by laravel. Additionally you can bind ‘verified’ Middleware to the routes protecting only verified users to pass through the URL.

You can read more at laravel email verification activation code tutorial that i wrote earlier to know more about it.

User.php
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
 
namespace App;
 
use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
 
class User extends Authenticatable implements MustVerifyEmail
{
    use Notifiable;
 
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'name', 'email', 'password',
    ];
 
    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];
}

Guest User Gates / Policies

Previously laravel used to return false automatically for unauthorized users when visitors visits the website. Now,we can allow guest users to pass through authorization checks declaring optional or supplying null value to the definition.

PHP
1
2
3
Gate::define('allow-guest', function (?User $user, Post $post) {
   /* ... */
});

Symfony Dump Server

Symfony dump server package is recently introduced by the community member of laravel whose name is Marcel Paciot. It is very useful to debug your application in runtime. You can check this by hitting php artisan dump-server.

To have a clean demo just add this in your routes/web.php.

1
2
3
4
Route::get('/demo', function(){
    $user = User::all();
    dd($user);
});

After activating the dump server just php artisan serve and hit the demo URL that we just added in the routes.

http://localhost:8000/demo

Laravel Symfony Dump Server Example
PHP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
C:\xampp\htdocs\laratutorials>php artisan dump-server
 
Laravel Var Dump Server
=======================
 
[OK] Server listening on tcp://127.0.0.1:9912
 
// Quit the server with CONTROL-C.
 
 
GET http://localhost:8000/demo/
-------------------------------
 
------------ ---------------------------------
  date         Sun, 09 Sep 2018 03:09:35 +0000
  controller   "Closure"
  source       web.php on line 26
  file         routes\web.php
------------ ---------------------------------
 
Illuminate\Database\Eloquent\Collection {#229
  #items: array:1 [
    0 => App\User {#230
      #fillable: array:3 [
        0 => "name"
        1 => "email"
        2 => "password"
      ]
      #hidden: array:2 [
        0 => "password"
        1 => "remember_token"
      ]
      #connection: "mysql"
      #table: null
      #primaryKey: "id"
      #keyType: "int"
      +incrementing: true
      #with: []
      #withCount: []
      #perPage: 15
      +exists: true
      +wasRecentlyCreated: false
      #attributes: array:8 [
        "id" => 1
        "name" => "Shashank Bhattarai"
        "email" => "Sorry i can show my email :)"
        "email_verified_at" => null
        "password" => "$2y$10$CTBQRlXUqpiqLaGa5Y/vquEIclrjBnud6YjiFX3GeDkuxuIpfJLmG"
        "remember_token" => "M00EIFz30Q7YPPmlywI7VwmO60eQXFXuXBlKgZIs2IL3r5dtJVia2dGGPUgZ"
        "created_at" => "2018-09-08 14:52:38"
        "updated_at" => "2018-09-08 14:52:38"
      ]
      #original: array:8 [
        "id" => 1
        "name" => "Shashank Bhattarai"
        "email" => "Sorry i can show my email :)"
        "email_verified_at" => null
        "password" => "$2y$10$CTBQRlXUqpiqLaGa5Y/vquEIclrjBnud6YjiFX3GeDkuxuIpfJLmG"
        "remember_token" => "M00EIFz30Q7YPPmlywI7VwmO60eQXFXuXBlKgZIs2IL3r5dtJVia2dGGPUgZ"
        "created_at" => "2018-09-08 14:52:38"
        "updated_at" => "2018-09-08 14:52:38"
      ]
      #changes: []
      #casts: []
      #dates: []
      #dateFormat: null
      #appends: []
      #dispatchesEvents: []
      #observables: []
      #relations: []
      #touches: []
      +timestamps: true
      #visible: []
      #guarded: array:1 [
        0 => "*"
      ]
      #rememberTokenName: "remember_token"
    }
  ]
}

You can get this dump server data by using php artisan dump-server --format=html > debugReport.html

Notification Localization

We can create notification and can only send in english language. But now laravel allows us to send rather than current language which is default set to English but also different language.

To get this result we need to use Illuminate\Notifications\Notification class which offers a new method called locale which can be used to set the desired language.

PHP
1
$user->notify((new UserActivate($user))->locale('np'));

We can also utilize the facade to set localization for multiple notifications.

PHP
1
2
Notification::locale('np')
        ->send($users, new SendEntries($entries));

Console Testing

New feature of laravel allows us to easily mock the data into our console commands. We can do this by using expectedQuestion(); function and specify the exit code that needed to be in output by using assetExitCode(); and expectedOutput();. We can be more clear by using the example below.

1
2
3
4
5
6
7
8
9
10
11
Artisan::command('question', function () {
    $pos= $this->ask('What is your position');
 
    $framework= $this->choice('Which Framework do you currently use in php?', [
        'Laravel Framework',
        'Zend Framework',
        'Yii Framework',
    ]);
 
    $this->line('Position : '.$pos.' and you program in '.$framework.'.');
});

URL Generator & Callable Syntax

In the past laravel only used to suport strings. But now it also supports callable array syntax. We can demonstrate by using the simple example.

Previously,

Routes
PHP
1
2
$url = action('HomeController@viewHomepage');
$url = action('HomeController@viewSinglePage', ['id' => 1]);

Now,

Routes
PHP
1
2
$url = action([HomeController::class, 'viewHomepage']);
$url = action([HomeController::class, 'viewSinglePage'], ['id' => 1]);

Paginator Links

In the past we cannot control the number of links inside the paginated URL. By default it was (3) on each site of the paginated links. But laravel recently intriuced the new method that we can use onEachSide() to control them in this version

PHP
1
{{ $posts->onEachSide(5)->links() }}

Filesystem Read / Write Steams

There is a new method for FileSystem integration in laravel 5.7

PHP
1
2
3
4
Storage::disk('s3')->writeStream(
'destination-doc.zip',
Storage::disk('local')->readStream('source-doc.zip')
);

These are the some major changes in laravel 5.7. Other than this there are some improvements in Error messages and directory changes inside the resources/views folder. Many files are moved to their own directory to solve the jumbled up problems.

Thanks for reading this article. Have you encountered any other changes, make sure to mention them in comments below.

SHARE ON
Buffer

Enjoyed this article?

Like us on

Laravel

Avatar for SNK

About SNK

Hello Welcome to my Blog. I develop Websites Using Laravel Framwork & WordPress. Get Latest updates on Facebook | Twitter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get Connected !! With Us

TOP POSTS

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

TUTORIALS TILL DATE

  • September 2022 (6)
  • June 2021 (7)
  • October 2020 (5)
  • September 2020 (6)
  • September 2018 (14)
  • August 2018 (3)
  • July 2018 (4)
  • March 2018 (8)
  • February 2018 (5)
  • January 2018 (1)
  • December 2017 (2)
  • August 2017 (8)
  • May 2017 (1)
  • April 2017 (1)
  • March 2017 (4)
  • February 2017 (3)
  • January 2017 (4)

CATEGORIES

  • Angular (2)
  • CSS3 (3)
  • D3 (3)
  • HTML5 (7)
  • JAVA (11)
  • Javascript (20)
  • jQuery (8)
  • Laravel (35)
  • Others (3)
  • PHP (11)
  • Spring (2)
  • WordPress (10)

Top Categories

  • Angular
  • CSS3
  • D3
  • HTML5
  • JAVA
  • Javascript
  • jQuery
  • Laravel
  • Others
  • PHP
  • Spring
  • WordPress

Get in Touch

DMCA.com Protection Status

Recent Articles

  • How to Setup Spring MVC Project From Scratch in Intellij IDEA ?
  • Spring Configuration Class in JAVA [Class VS XML Config]
  • Annotations Based Configuration in Spring Framework
  • How to Configure Spring Framework with XML Configurations?
  • How to Remove Project Name from URL in JSP Project in Intellij IDEA ?

© 2012-22 CodeIn House.  •  All Rights Reserved.