15 Essential Packages For Extending Laravel

Laravel is one of the most popular PHP frameworks for developing web applications. It offers a number of great features such as simple and fast routing, different ways for accessing relational databases, powerful dependency injection and much more.

In this article we are going to share with you 15 excellent open-source PHP libraries for extending Laravel. You can easily include them in any Laravel project to add various utilities and improve your workflow.


Laravel Debugbar

A package for Laravel 5 which adds a developer toolbar for debugging the PHP and Laravel code of your app. There are lots of options which allow you to show all queries, get information about the current Route, show the currently loaded Views, and much more.

// All arguments will be dumped as a debug message
debug($var1, $someString, $intValue, $object);

// Measure render time or other events.
start_measure('render','Time for rendering');
stop_measure('render');
add_measure('now', LARAVEL_START, microtime(true));
measure('My long operation', function() {
    // Do something…
});

Entrust

Entrust is a Laravel 5 package which gives you a flexible way to add role-based permissions to your project. The library creates four new tables: roles, permissions, role_user and permission_role, which you can use to set up roles with different levels of access.

// Creating role and permissions
$admin = new Role();
$admin->name = 'admin';
$admin->display_name = 'User Administrator'; // optional
$admin->description  = 'User is allowed to manage and edit other users'; // optional
$admin->save();

Socialite

Socialite offers a simple and easy way to handle OAuth authentication. It makes it possible for your users to log-in via some of the most popular social networks and services including Facebook, Twitter, Google, GitHub and BitBucket.

$user = Socialite::driver('github')->user();

// OAuth Two Providers
$token = $user->token;
$refreshToken = $user->refreshToken; // not always provided
$expiresIn = $user->expiresIn;

// All Providers
$user->getId();
$user->getName();
$user->getEmail();
$user->getAvatar();

User Verification

A package that allows you to verify users and validate emails. It generates and stores a verification token for the registered user, sends an email with the verification token link, handles the token verification, and sets the user as verified.

protected function validator(array $data)
{
    return Validator::make($data, [
        'name' => 'required|max:255',
        'email' => 'required|email|max:255|unique:users',
        'password' => 'required|min:6|confirmed',
    ]);
}

Tinker

Tinker allows you to interact with your entire Laravel application from the command line and access all the Eloquent jobs, events, and objects. It used to be part of Laravel, but after version 5.4 it is in a optional add-on that needs to be installed separately.


Breadcrumbs

With this package you can create breadcrumb page controls in a simple and easy way. It supports some of the most popular front-end frameworks such as Bootstrap, Bulma, Foundation and Materialize.

// Home > Photos
Breadcrumbs::register('photo.index', function ($breadcrumbs) {
    $breadcrumbs->parent('Home');
    $breadcrumbs->push('Photos', route('photo.index'));
});

//  Home > Photos > Upload Photo
Breadcrumbs::register('photo.create', function ($breadcrumbs) {
    $breadcrumbs->parent('photo.index');
    $breadcrumbs->push('Upload Photo', route('photo.create'));
});

Eloquent-Sluggable

Slugging is creating a simplified, URL-friendly version of a string by converting it to one case and removing spaces, accented letters, ampersands, etc. With Eloquent-Sluggable you can easily create slugs for all the Eloquent models in your project.

class Post extends Eloquent
{
    use Sluggable;
    protected $fillable = ['title'];
    public function sluggable() {
        return [
            'slug' => [
                'source' => ['title']
            ]
        ];
    }
}

$post = new Post([
    'title' => 'My Awesome Blog Post',
]);
// $post->slug is "my-awesome-blog-post"

Migrations Generator

A Laravel package which can be used to generate migrations from an existing database, including indexes and foreign keys. When you run the following command you can create migrations for all the tables in your database.

 php artisan migrate:generate

You can also choose only certain tables that you want to use:

 php artisan migrate:generate table1,table2 

NoCaptcha

Laravel 5 package for implementing Google's reCAPTCHA "I'm not a robot" validation and protecting your forms from spam. To use the service you will need to obtain a free API key.

// prevent validation error on captcha
NoCaptcha::shouldReceive('verifyResponse')
    ->once()
    ->andReturn(true);
// provide hidden input for your 'required' validation
NoCaptcha::shouldReceive('display')
    ->zeroOrMoreTimes()
    ->andReturn('');
    

Artisan View

A command line utility that adds a number of Artisan commands for working with the views in your app. It allows you to automatically generate view templates without having to manually create new blade files.

# Create a view 'index.blade.php' in the default directory
$ php artisan make:view index

# Create a view 'index.blade.php' in a subdirectory ('pages')
$ php artisan make:view pages.index

# Add a section to the view
$ php artisan make:view index --section=content

Laravel Backup

With this Laravel package you can back up all of the files in your project. All you need to do is run this command:

php artisan backup:run

It creates a zipfile with all the files in the directory and a dump of your database. Can be stored on any file system.


CORS Middleware

Setting up CORS (Cross-Origin Resource Sharing Headers) on your website can be a lot of work. With this Laravel library the configuration process is very simplified. It handles CORS pre-flight options requests and adds CORS headers to your responses

return [
    'supportsCredentials' => false,
    'allowedOrigins' => ['*'],
    'allowedHeaders' => ['Content-Type', 'X-Requested-With'],
    'allowedMethods' => ['*'], // ex: ['GET', 'POST', 'PUT',  'DELETE']
    'exposedHeaders' => [],
    'maxAge' => 0,
]

Laravel GraphQL

GraphQL is a data query language that provides an alternative to traditional REST architectures. Developers define the structure of the data required, and get exactly the same structure from the server. This package will help you set up and use GraphQL in your Laravel apps.


Laravel Mix

Laravel Mix provides a rich API for defining Webpack build steps for your project. It uses a few common CSS and JavaScript pre-processors that can be chained together to transform and format your assets.

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

Laravel Extended Generators

A library by the team from Laracasts that offers a number of generators that can save you a lot of time when developing your project. It allows you to quickly setup new models, views, controllers, migrations, seeds, and more.

Presenting Bootstrap Studio

a revolutionary tool that developers and designers use to create
beautiful interfaces using the Bootstrap Framework.

Learn more
Web Browser Frame DevKit Box Mouse Cursor

Related Articles

Comments 2

  • Thanks for this list guys :)
    I also use Voyager Laravel Package for the admin pannel. All functions for a good administrator + BREAD for use our SGBD ;)