Here are the 10 Most Useful Laravel Packages Can Help You to code easier. If you look at the number of downloads per package, obviously you can tell which ones are the most popular. 


Entrust is a succinct and flexible way to add Role-based Permissions to Laravel 5. This package provides a flexible way to add Role-based Permissions to Laravel . this is why route middleware unraavelled in laravel

In order to install Laravel 5 Entrust, just add

"zizaco/entrust": "5.2.x-dev"

to your composer.json. Then run composer install or composer update.

Then in your config/app.php add


in the providers array and

    'Entrust'   => Zizaco\Entrust\EntrustFacade::class,

to the aliases array.

If you are going to use Middleware (requires Laravel 5.1 or later) you also need to add

    'role' => \Zizaco\Entrust\Middleware\EntrustRole::class,
    'permission' => \Zizaco\Entrust\Middleware\EntrustPermission::class,
    'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,

to routeMiddleware array in app/Http/Kernel.php.

if you want to create ecommerce site using laravel . this tutorial is for you


2. laravelcollective/html


This one replaces the light up/html class, since that class is no more bolstered and is no more incorporated into the center as of laravel 5. This bundle is crucial, in the event that you like utilizing the form model binding

{!! Form::model($marketingImage, ['route' => ['marketingimage.destroy', $marketingImage->id],
        'method' => 'DELETE',
        'class' => 'form',
        'files' => true]
        ) !!}

But obviously this is not completely necessary, which is why it’s no longer in the core. You could simply create a form manually using bootstrap. You just have to remember to add:

 <input type="hidden" name="_token" value="{{ csrf_token() }}">

That will add your csrf token to the post data.

So obviously, using the Form helper does this for you, which is why I use it when I can. I find it very convenient.

When you are installing this, you will see instructions for adding the ‘Form’ alias. Please note that the bootstrapper package has Form alias as well and you cannot use both, because it will cause a conflict. So I solved this by simply not including the alias for the bootstrapper form alias.

Also note: Most instructions for adding to providers array and the alias array are not using the new PHP ::class syntax. I recommend using the new syntax, which is better to use because you can use your IDE to click into the class.

So for example, old style alias:

'Form'  => 'Collective\Html\FormFacade',

New style:

'Form'  => Collective\Html\FormFacade::class,

You can do the same for the providers, in this case it’s the html provider:



3. laravel-cors

The laravel-cors package allows you to send Cross-Origin Resource Sharing headers with ACL-style per-url configuration.

If you want to have have a global overview of CORS workflow, you can browse this image.


  • Handles CORS pre-flight OPTIONS requests
  • Adds CORS headers to your responses


The defaults are set in `config/cors.php’. Copy this file to your own config directory to modify the values. You can publish the config using this command:

php artisan vendor:publish --provider="Barryvdh\Cors\ServiceProvider"

Note: When using custom headers, like X-Auth-Token or X-Requested-With, you must set the allowedHeaders to include those headers. You can also set it to array('*') to allow all custom headers.

Note: If you are explicitly whitelisting headers, you must include Origin or requests will fail to be recognized as CORS.

return [
    'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedHeaders' => ['Content-Type', 'Accept'],
    'allowedMethods' => ['GET', 'POST', 'PUT',  'DELETE'],
    'exposedHeaders' => [],
    'maxAge' => 0,
    'hosts' => [],

allowedOrigins, allowedHeaders and allowedMethods can be set to array('*') to accept any value, the allowed methods however have to be explicitly listed.

Note: Because of http method overriding in Laravel, allowing POST methods will also enable the API users to perform PUT and DELETE requests as well.


Require the barryvdh/laravel-cors package in your composer.json and update your dependencies.

$ composer require barryvdh/laravel-cors

Add the Cors\ServiceProvider to your config/app.php providers array:



The ServiceProvider adds a route middleware you can use, called cors. You can apply this to a route or group to add CORS support.

Route::group(['middleware' => 'cors'], function(Router $router){
    $router->get('api', 'ApiController@index');

If you want CORS to apply for all your routes, add it as global middleware:


4. Lumen

On Laravel Lumen, use LumenServiceProvider:


And load your configuration file manually:



5. laracasts/flash

This is a nice handy helper to make your flash message syntax in your controller beautiful:

flash()->success('Marketing Image Created!');


This one gives us an artisan command for creating pivot table migrations.

6. proxy

With this packages you can Set trusted proxies for Laravel . learn how to protect your laravel app from bots and spammers around the web

Laravel 5 has a much nicer system for Middleware, which this package now takes advantage of.

New features include:

  1. TrustedProxies are now set as in an HTTP Middleware, which makes more logical sense than the previous ServiceProvider. If you’re unsure what that means, remember to “Just Trust Fideloper™”.
  2. You can now set the trusted header names. This is useful for proxies that don’t use the usual X-Forwarded-* headers.

To use this with Laravel 5, run the following from your Laravel 5 project directory:

composer require fideloper/proxy

Or of course, you can edit your composer.json file directly:

    "require": {
        "fideloper/proxy": "^3.1"


Setting a trusted proxy allows for correct URL generation, redirecting, session handling and logging in Laravel when behind a proxy.

This is useful if your web servers sit behind a load balancer, HTTP cache, or other intermediary (reverse) proxy.


Install Trusted Proxy:

$ composer require fideloper/proxy

Add the Service Provider:

'providers' => array(
    # other providers omitted

Publish the package config file to config/trustedproxy.php:

$ php artisan vendor:publish

Register the HTTP Middleware in file app/Http/Kernel.php:

    protected $middleware = [
        // Illuminate middlewares omitted for brevity


Then edit the published configuration file config/trustedproxy.php as needed.

The below will trust a proxy, such as a load balancer or web cache, at IP address


return [
    'proxies' => [

    // These are defaults already set in the config:
    'headers' => [
        \Illuminate\Http\Request::HEADER_CLIENT_IP    => 'X_FORWARDED_FOR',
        \Illuminate\Http\Request::HEADER_CLIENT_HOST  => 'X_FORWARDED_HOST',
        \Illuminate\Http\Request::HEADER_CLIENT_PROTO => 'X_FORWARDED_PROTO',
        \Illuminate\Http\Request::HEADER_CLIENT_PORT  => 'X_FORWARDED_PORT',


8. Eloquent-sluggable

This package helps Easy creation of slugs for your Eloquent models in Laravel .

Background: What is a slug?

A slug is a simplified version of a string, typically URL-friendly. The act of “slugging” a string usually involves converting it to one case, and removing any non-URL-friendly characters (spaces, accented letters, ampersands, etc.). The resulting string can then be used as an indentifier for a particular resource.

For example, I have a blog with posts. I could refer to each post via the ID:

… but that’s not particularly friendly (especially for SEO). You probably would prefer to use the post’s title in the URL, but that becomes a problem if your post is titled “My Dinner With André & François”, because this is pretty ugly too:

The solution is to create a slug for the title and use that instead. You might want to use Laravel’s built-in Str::slug() method to convert that title into something friendlier:

A URL like that will make users happier (readable, easier to type, etc.).

For more information, you might want to read this description on Wikipedia.

Slugs tend to be unique as well. So if I wrote another post with the same title, I’d want to distinguish between them somehow, typically with an incremental counter added to the end of the slug:

This keeps URLs unique.

The Eloquent-Sluggable package for Laravel 5 will handle all of this for you automatically, with minimal configuration at the start.

Installation and Requirements

First, you’ll need to require the package with Composer:

composer require cviebrock/eloquent-sluggable

NOTE: Eloquent-Sluggable now uses traits, so you will need to be running PHP 5.4 or higher. If you are still using 5.3, then use the “1.*” version and follow the instructions in that version’s file.

Aftwards, run composer update from your command line.

Then, update config/app.php by adding an entry for the service provider.

'providers' => [
    // ...

Finally, from the command line again, run php artisan vendor:publish to publish the default configuration file.

Updating your Eloquent Models

Your models should implement Sluggable’s interface and use it’s trait. You should also define a protected property $sluggable with any model-specific configurations

use Cviebrock\EloquentSluggable\SluggableInterface;
use Cviebrock\EloquentSluggable\SluggableTrait;

class Post extends Model implements SluggableInterface
    use SluggableTrait;

    protected $sluggable = [
        'build_from' => 'title',
        'save_to'    => 'slug',


Of course, your database will need a column in which to store the slug. You can do this manually, or use the built-in artisan command to create a migration for you. For example:

php artisan sluggable:table posts

Running that command will create a migration that adds a column named “slug” to your posts table. If you want to use a different name for the slug column, you can provide that as a second argument:

php artisan sluggable:table posts slug_column

Be sure to set your model’s save_to configuration to match the column name.

After generating the migration, you will need to rebuild composer’s auto-loader and run the migration:

composer dump-autoload
php artisan migrate

That’s it … your model is now “sluggable”!


Using the Class

Saving a model is easy:

$post = new Post([
    'title' => 'My Awesome Blog Post',


And so is retrieving the slug:

echo $post->slug;

// or, if you don't know the name of the slug attribute:
echo $post->getSlug();

Also note that if you are replicating your models using Eloquent’s replicate() method, then you will need to explicity tell the package to force a re-slugging of the model afterwards to ensure uniqueness:

$new_post = $post->replicate()->resluggify();

There is also a handy helper in the trait for finding a model based on it’s slug:

$post = Post::findBySlug('my-slug');

This is basically a wrapper for Post::where('slug-field','=','my-slug')->first().
If your slugs aren’t unique, then use the getBySlug() method which will return an Eloquent collection.

You can also use the static method Post::createSlug('My First Post') to generate a slug for a given string, without actually creating or saving an associated model. This would be useful for Ajax-y controllers or the like, where you want to show a user what the unique slug would be for a given input, before actually creating a model.


9. barryvdh/laravel-debugbar

This is an absolute must for development. It installs a debug bar that sits at the bottom of the page that gives you helpful information on routes, DB queries and more.


10. patricktalmadge/bootstrapper

This is a pretty wrapper for a lot of bootstrap stuff. I haven’t gone too far deep into it, but I do use the breadcrumb widget. As I noted in the laravel collective html package, there is a conflict with the form alias, so leave that one out when you are updating the aliases array in config/app.php.