What are the new features in Laravel 5.5

What are the new features in Laravel 5.5

What are the new features in Laravel 5.5

The Laravel community is always ready to launch the new features with its upgraded version and I have too much interest about upcoming features in Laravel.

You will have to upgrade your PHP version if you have installed older than 7.0 because Laravel 5.5 will require PHP 7.0+.

LTS Release

After Laravel 5.1, for LTS release, You will get a long term support policy with Laravel 5.5 including 2 years bug fixes and 3 years security fixes.

Whoops features back in Laravel 5.5

whoops is an error handler framework for PHP used with Laravel 4 but it was removed from Laravel 5.0

whoops provide a nice, clean and elegant interface for error that notify you the error line in the file where you exactly get the error.

Now you can directly open referenced files directly in your editor from whoops interface.

You can set your installed editor in handler file to overrides the whoopsHandler() method.

Return request data from validation

There are two changes in validation rules in Laravel 5.5. Now you can directly call the validate method on the request, before you pass the request instance as a first argument to validate request data, but with the release of Laravel 5.5, there is no need to pass request instance as a second argument.

  1. public function store()
  2. {
  3. $data = request()->validate([
  4. 'name' => 'required',
  5. 'email' => 'required'
  6. ]);
  7. return Member::create($data);
  8. }

And second changes is, You can get the request data after validation in a variable and directly save the data after validation.

  1. public function store()
  2. {
  3. $data = request()->validate([
  4. 'name' => 'required',
  5. 'email' => 'required'
  6. ]);
  7. // $data = request()->only('name', 'email');
  8. return Member::create($data);
  9. }

But make sure if any attributes which is not required should be defined with the empty rules because you may lose the data, if any attributes which is left out from the validation method.

  1. public function store()
  2. {
  3. $data = request()->validate([
  4. 'name' => 'required',
  5. 'email' => 'required',
  6. 'notRequiredField'=>'',
  7. ]);
  8. return Member::create($data);
  9. }
Custom Validation Rules

Now you can create your own custom validation rules with Laravel 5.5

With the older version, there was facility to add custom validation rules via Closures using Validator::extend method but with Laravel 5.5, You will get a dedicated class to handle the custom rules and also you can use artisan command to create a class for custom validation :

php artisan make:rule CustomValidName

You will get the class CustomValidName in app/Rules directory with two methods :passes and message

passes method will have two method $attribute and $value and validate if attribute value is valid then return true otherwise return false and message method return the respected error message when validation fails.

Click here to see the full example Custom Validation Rules

Blade::if Directives

With Laravel 5.5, You can define custom if blade directives for the different different scenarios.

Click here to see the full example Blade::if Directives Route Helpers

Now you can use some helpful method with your Route, click here to know more about the Route Helpers

Laravel Migrate Fresh Command

There is a new feature added with migrate: namespace in Laravel 5.5.

Before Laravel 5.5, You were using the migrate:refresh command to roll back your existing migrations but with the new release of Laravel 5.5, There is an improvement with migrate:fresh command that drops all the table and then migrate it from start.

By running migrate:refresh command, You will see the following output on your terminal :

$ php artisan migrate:refresh

Output :

Rolling back: 2014_10_12_100000_create_password_resets_table
Rolled back: 2014_10_12_100000_create_password_resets_table

Rolling back: 2014_10_12_000000_create_users_table
Rolled back: 2014_10_12_000000_create_users_table


Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table

Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table

Now run the migrate:fresh command and see the output :

$ php artisan migrate:fresh

Output :

Dropped all tables successfully.
Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated:  2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated:  2014_10_12_100000_create_password_resets_table
Support for Email Themes in Mailable

Laravel 5.4 offers Markdown emails that provide a default theme to compose emails in Markdown, but with the release of Laravel 5.5, There is much more flexibility to use email theme directly in the Mailable class.

You will have to write your styles in .css file to use custom theme for a specific mailable.

touch resources/views/vendor/mail/html/themes/custom.css

Now you can specify a $theme property in the Mailable class :

  1. class SendNotification extends Mailable
  2. {
  3. protected $theme = 'custom';
  4. [...]
  5. }

Phone: (+91) 8800417876
Noida, 201301
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort otele gelen escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort akyazı escort arifiye escort erenler escort eve gelen escort ferizli escort geyve escort hendek escort karapürçek escort karasu escort kaynarca escort kocaali escort otele gelen escort pamukova escort sapanca escort söğütlü escort taraklı escort
sakarya escort serdivan escort adapazarı escort sakarya escort bayan sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sakarya escort sapanca escort sakarya escort escort bayan