Home / Web Development Technologies / Laravel / What’s New in Laravel 5

What’s New in Laravel 5


What’s New in Laravel 5

1. Directory Structure

The envelope structure of a Laravel venture has experienced a noteworthy update. Laravel 5 implements the PSR-4 autoloading standard, which implies every one of your classes are totally namespaced. The default namespace for your web application is app, which you can change utilizing the php artisan app:name <your-application name> command.

Your models fall under the default app namespace and are inside the application organizer. Your application’s advantages, perspectives, and dialect records are in the assets envelope(folder).The vendor, public,and bootstrap registries hold their place as in the more seasoned adaptations of the structure, while the config, stockpiling, database, and tests indexes have been moved to the base of the task.

On the off chance that you look inside the application envelope, you will see a great deal of classes, however don’t stress over them for the time being—we are going to get into that throughout this articl

Environment location has been immensely moved forward. Rather than all the complex settled design registries, you have an .env record at the foundation of your undertaking to deal with the application environment and all the environment variables. Additionally, the php artisan tinker summon now uses the Psysh bundle rather than Boris..

System infusion has been extraordinarily rearranged. Until variant 4.2, you needed to ask for the Inversion of Control (IoC) compartment to give a class case or make it in your controller’s constructor to make it available under the class scope. Presently,  you can declare the type hinted class example in the controller system’s mark and the IoC compartment will deal with it, regardless of the possibility that there are various parameters in your controller capacity’s mark

// your class at "app/Classes/your_class.php"
namespace App\Classes
class YourClass
    // your class implementation
// somewhere in one of your controller actions
public function myAction(\App\Classes\YourClass $MyObject)
    // use $MyObject just like any other object
 Contracts are really interface classes in disguise. Interfaces are an attempted and tested method for removing class dependency and growing approximately coupled programming parts. They by and large offer you some assistance with following the “rely on upon deliberations, not abstractions” guideline.
Laravel becomes tied up with the same philosophy. The greater part of the significant center segments make utilization of these agreements to keep the framework loosely coupled. You can likewise use them in your  package development.
For instance, if your bundle requires reserving, then as opposed to utilizing a solid store class, you can actualize the Illuminate\Contracts\Cache interface and you will be allowed to connect the reserve usage to and out without changing quite a bit of your bundle code..
You may get some information about making sense of the usage for a particular contract. All that enchantment happens inside the Illuminate\Foundation\Application.php record.

Artisan has another route caching feature. Route reserving massively accelerates your application’s route registration, with unmistakably noticeable execution advantages. Be that as it may, if your application bargains in a little number of routes, you won’t not see the effect route storing should have, which implies it is more suited to situations where your application has an large number of routes

The commands php artisan route:cache and php artisan route:clear turn course storing on and off respectively. Once route storing is turned on, any adjustments you make to the application routes won’t produce results. Route caching would by and large be actualized as a feature of your arrangement process

Middleware can be utilized to add additional layers to your HTTP routes. On the off chance that you need code to execute before each routesor before particular routes in your application, then such a bit of code is a solid match for a middleware class.

For instance, suppose you need to shut out a certain range of IPs from your application to make your application unavailable in that region. In such a case, you should check the client IP before every request and allow/disallow them entry to your application. This will be a considerable measure to do in your controller actions, so you will utilize middleware. Create a middleware class at

app/Http/Middleware/RegionMiddleware.php by using php artisan make:middleware "RegionMiddleware"

namespace app\Http\Middleware;
use Closure;
class RegionMiddleware {
     * Handle an incoming request.
     * @param  \Illuminate\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
    public function handle($request, Closure $next)
        // perform some IP logic on $request
        // and redirect to appropriate
        // page based on results
        // everything went well
        // this will resume normal flow
        return $next($request);

You can then register your middleware in the app/Http/Kernel.php file by appending it to the $middleware array. In such a case, you should check the client IP before every request and allow/disallow them entry to your application. This will be a considerable measure to do in your controller actions, so you will utilize middleware. Create a middleware class at

Check Also

AngularJS and Laravel Blade

How to use AngularJS and Laravel Blade together

How to use AngularJS and Laravel Blade together In this article I will show you …

Ajax Pagination Using Laravel

How to Create an Ajax Pagination Using Laravel

In this article I will demonstrate one way to create an Ajax pagionation using Laravel …

One comment

  1. wow great website looking forward for some more great tutriols

Leave a Reply

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