Wednesday 16 August 2017

New Features in Laravel 5.5 Your Next Project


New Features in Laravel 5.5:

1. Frontend Presets
2. DD and Dump for Easy Debugging
3. Custom Email Theme Setup
4. Custom Validation Rule
5. Laravel 5.5 Require PHP 7+
6. Laravel Auto Package Discovery

1. Frontend Presets


As we all know Laravel 5.4 have vue.js as preset front end JavaScript but Laravel 5.5 will be introduced with 3 front ends preset: Vue.js as default, react.js and bootstrap, you can change as per your preference.

you can change the preset to bootstrap using this command:


php artisan preset bootstrap



We can change the preset to react and vue by replacing the bootstrap in above command, Laravel 5.5 will also provide the option to remove the all 3 to load your own JavaScript or PHP backend only app by the following command:

php artisan preset none

2. DD and Dump for Easy Debugging 

 In collection class of Laravel 5.5, two methods will be introducing for easy debugging-DD and Dump, let’s understand by simple example:

collect([1,2,3])->map(function($i){
   return $i * 3;
})->reject(function($i){
   return $i < 3;
});


In above condition knowing the all step of each chain may be difficult so you can dump at some point.

collect([1,2,3])->map(function($i){
   return $i * 3;
})->dump()->reject(function($i){
   return $i < 3;
});


3. Custom Email Theme Setup

Today’s new era of software industry brand expression is most important in every process of the product while a user interacts with it, In an earlier version of laravel we can easily send the email but has been sent using default email template. If you want to use your branding in Laravel 5.4 then you need to follow below steps:

You can start by generating a CSS file containing your custom styling like below:
// my-design.css is the name of your theme
resources/views/vendor/mail/html/themes/my-design.css


Now update the markdown option of your mail.php config file:

'markdown' => [
  'theme' => 'my-design',
  'paths' => [
    resource_path('views/vendor/mail'),
   ],
],


In Laravel 5.5, we can send the custom email template with your perfect branding more easily. i.e you wanted to send the notification email to users then you can write your own CSS.

//Create css style sheet
resources/views/vendor/mail/html/themes/techuzITFirm.css


Now define $theme property that references your new theme on any Mailable class

class SendInvoice extends Mailable

{
protected $theme = 'techuzITFirm';
...
}


4. Custom Validation Rule

Laravel 5.5 will introduce the dedicated class to handle the validation, to define the custom validation rule you need to create the class with two methods: Passes and message, let’s take an example to understand better:

<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class HireProfessionalLaravelDeveloperIndia implements Rule
{
  public function passes($attribute, $value)
  {
   return $value > 5;
  }
  public function message()
{
    return ':attribute needs more Developers!';
  }
}

5. Laravel 5.5 Require PHP 7+

Laravel 5.5 will have PHP 7+ version, it will improve the speed of web application and will save a cost for your project. You can check the report of engineering team of tumblr who have recently implemented the PHP 7+ version
“Almost immediately saw the latency drop by half, and the CPU load on the servers decrease at least 50%, often more. Not only were our servers serving pages twice as fast, they were doing it using half the amount of CPU resources – Tumbler engineering report“
“Etsy is a popular PHP-based online marketplace for handmade and vintage goods that has been in operation since 2005 (29 million items listed on its website, 54 million registered users, among them 1.4 million active sellers, and 19.8 million active buyers). Initially it was written in PHP 5, and later, was switched to HHVM (Virtual Machine for PHP). After migration to PHP 7, Etsy was significantly better from such perspectives as the memory and system/user CPU usage, homepage/listing delivery speed and number of hosting servers – Etsy Case Study

6. Laravel Auto Package Discovery


In earlier version developer had to write the following package step to register its service providers and adding aliases before pulling, Laravel 5.5 have new cool way for package developer, you can review the Taylora’s post for more detail.
Install the package:

composer require school/kids

School/Kids\ServiceProvider::class,
‘Bar’ => School/Kids\Facade::class,


New cool way to write the pull request automatically register service providers and add aliases through the package’s composer.json in Laravel 5.5

"extra": {
   "laravel": {
    "providers": [
     "School\\Kids\\ServiceProvider"
   ],
    "aliases": {
    "Bar": "School\\Kids\\Facade"
    }
   }
}


Register the provider in app.php:
Optionally, register Facade:
 

Monday 14 August 2017

How to install Laravel 5.5 project from scratch


Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

Via Laravel Installer

composer global require "laravel/installer"

Once installed, the laravel new command will create a fresh Laravel installation in the 
directory you specify. For instance, laravel new blog will create a directory named blog 
containing a fresh Laravel installation with all of Laravel's dependencies already installed:

laravel new Laraquery

Via Composer Create-Project

Alternatively, you may also install Laravel by issuing the Composer create-project command in your terminal:
composer create-project --prefer-dist laravel/laravel blog 

Source: www.laravel.com 

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in Laravel

  WampServer: Download this file:  http://curl.haxx.se/ca/cacert.pem Place this file in the  C:\wamp64\bin\php\php7.1.9  folder Open  php.in...

Popular Articles