AppDividend
Latest Code Tutorials

Laravel 5.7 Features and Updates | What Is New

3,373

Get real time updates directly on you device, subscribe now.

In this post, we will talk about Laravel 5.7 Features and Updates | What Is New. Laravel 5.7 has some new cool features as well as several other enhancement and bug fixes. We will discuss some of the noticeable changes and some of the new additions to the Laravel 5.7 family.

If you want to master in Laravel then check out this course. It has everything you want to know.
PHP with Laravel for beginners – Become a Master in Laravel

Laravel 5.7 Features and Updates

In previous Laracon event, Taylor Otwell announced some of the changes which are the following.

  1. Resources Directory Changes.
  2. Callable Action URLs.
  3. Laravel Dump Server.
  4. Improved Error Messages For Dynamic Calls.

Install Laravel 5.7 From Develop Branch

You can install the latest Laravel by typing the following command.

composer create-project laravel/laravel test dev-develop

 

Laravel 5.7 Features and Updates | What Is New

#Laravel 5.7 Resources Directory Changes

If you open the test project in a code editor, you can see the directory structure changes. Resources directory will be flattened instead of having an assets folder.

 

Laravel 5.7 Resources Directory Changes

To update from Laravel 5.6 to 5.7, You could even make a move now in your Laravel 5.6 assets ahead of this change. First, you need to update your Laravel Mix configuration.

Earn a Tech Degree and get the skills like Frontend Development or Javascript Development that can help you to launch a career. Join the program
let mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');

Then you can move the directories and clean up with the following.

mv resources/assets/* resources
rm -Rf resources/assets/

#Laravel 5.7 Callable Action URLs

A new callable-like syntax for action URLs is coming to Laravel 5.7. You might also hear this feature called “tuple notation” or a “callable array syntax” for URL generation actions.

Here’s how it works starting in 5.7:

<?php

$url = action([UserController::class, 'index']);

As of Laravel 5.6 the action helper only supports the following style that you’re probably already familiar with:

<?php

$url = action('UserController@profile', ['id' => 1]);

The benefit of the new callable array syntax format is that you can able to navigate to directly to the controller file if you use a text editor like VSCode or Sublime or Atom or IDE like phpStorm that supports code navigation.

#Laravel Dump Server

Laravel Dump Server would come packaged with Laravel 5.7Dump Server will be the development dependency in laravel/laravel composer file. You’ll get this command out-of-the-box that allows you to dump data to the console or an HTML file instead of to the browser.

php artisan dump-server

 

Laravel Dump Server

#Laravel 5.7 Improved Error Messages for Dynamic Calls

Related Posts
1 of 39

Laravel 5.7 makes it easier to track down error messages caused by dynamic calls to Eloquent models. You’ll get a more clear picture of the error caused by a missing method instead of a possibly confusing error on the underlying object.

Want to learn to code, gain a new skill and get a new job. Check out this amazing program

#Laravel 5.7 Email Verification

Laravel 5.7 introduces optional email verification to the authentication scaffolding included with the framework. To accommodate this feature, an email_verified_at timestamp column has been added to the default users table migration that is included with the structure. To prompt newly registered users to verify their email, the User model should be marked with the MustVerifyEmail interface:

<?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
{
    // ...
}

#Guest User Gates / Policies

In previous versions of Laravel, authorization gates and policies automatically returned falsefor unauthenticated visitors to your application. However, you may now allow guests to pass through authorization checks by declaring an “optional” type-hint or supplying a null default value for the user argument definition:

Gate::define('update-post', function (?User $user, Post $post) {
    // ...
});

#Paginator Links

Laravel 5.7 allows you to control how many additional links are displayed on each side of the paginator’s URL “window.” By default, three links are displayed on each side of the primary paginator links. However, you may control this number using the onEachSide method:

{{ $paginator->onEachSide(5)->links() }}

#Filesystem Read / Write Streams

Laravel’s Flysystem integration now offers readStream and writeStream methods:

Storage::disk('s3')->writeStream(
    'remote-file.zip',
    Storage::disk('local')->readStream('local-file.zip')
);

#Laravel Nova

Laravel Nova is not a feature of Laravel. It is a different package that is created by Taylor Otwell. 

Laravel Nova is a beautiful, best-in-class administration dashboard for Laravel applications. Of course, the primary feature of Nova is the ability to administer your underlying database records using Eloquent. Additionally, Nova offers support for filters, lenses, actions, queued actions, metrics, authorization, custom tools, custom cards, custom fields, and more.

To learn more about Laravel Nova, check out the Nova website.

So these are packages and Laravel 5.7 Features and Updates

5 Comments
  1. almokhtar says

    Thank you for this info .
    note : i think your website slow i don’t know if that because hight traffic or something else .

    1. MODI says

      yes

  2. Virendra Arekar says

    Awesome,Your tutorial always simple and well understranding..

  3. Virendra Arekar says

    Awesome,your tutorial always simple and well understanding.

  4. Bobby says

    Thanks Krunal !! you are a good guy.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.