Laravel packages are great for extending the power of Laravel application. Laravel gives you the flexibility to develop your custom package. So that you can develop your laravel package according to your need. The Laravel community continuously developing useful packages day by day. Some of the packages are cool & awesome and most Laravel developer already uses those laravel packages in their application. In this article, I'll share with you the top 10 laravel packages that will help you to develop awesome laravel application.
Form design is the most common part of a website or web application development. Although you can make a form from scratch it's a time-consuming and less productive process. In this scenario, Laravel H package provides such a clean and nice facade for building form element like form, input, radio, select box etc.
Installation
composer require haruncpi/laravel-h
Usages
{!! F::open(['url' => 'foo/bar']) !!}
{!! F::input('name') !!}}
{!! F::close() !!}
or you can use like f()->method()
{!! f()->open(['url' => 'foo/bar']) !!}
{!! f()->input('name') !!}}
{!! f()->close() !!}
Doc Laravel H
Image uploading, resizing, making custom image and manipulation is a common task for any web application. The Laravel intervention image package gives an easier way to create, edit, and compose images.
Installation
composer require intervention/image
Usages
Resizing an image
$img = Image::make('public/myimage.jpg');
$img->resize(320, 240);
$img->save('public/final.jpg');
Insert watermark
$img = Image::make('public/myimage.jpg');
$img->insert('public/watermark-logo.png');
$img->save('public/final.jpg');
For auditing, your application exceptions the Laravel Log Reader package is very handy and useful. You will get entire application errors and exception logs dashboard via this package. It'll help you to find your application's errors easily so that you can fix those errors quickly. It has many features like viewing logs date by date, log filtering, log clearing by UI, JSON log API and more.
Installation
composer require haruncpi/laravel-log-reader
Publishing config
php artisan vendor:publish --provider="Haruncpi\LaravelLogReader\ServiceProvider" --tag="config"
Usages
The usages of this package so simple. Just go to the URL http://example.com/admin/log-reader
Every developer wants to enhance the application performance and want to easily find out what exactly happened during throwing an exception. In this scenario, the laravel debug bar package provides query log, execution time, memory usages, timeline, request payload and more.
Installation
composer require barryvdh/laravel-debugbar --dev
Usages
In your development environment, you will see a bar will show in your UI part containing query log, execution time, memory usages, timeline, request payload and more. You can also send any debug data in the debug bar where we are used to var_dump()
or dd()
functions which are not convenient in this way.
Debugbar::info($yourobject);
Debugbar::error('Any error message!');
Debugbar::warning('Watch out the message');
Debugbar::addMessage('Another message', 'my_level');
Doc Larave Debug Bar
Laravel Acl is a package for managing user and permissions. There are more package deal with user management and permissions but the Laravel ACL offer simple and clean API to handle user and permissions. It provides nice well documentation. By this package, you can handle user's permission and group-wise permissions.
Installation
composer require mateusjunges/laravel-acl
php artisan acl:install
Publishing migrations file
php artisan vendor:publish --provider="Junges\ACL\ACLServiceProvider" --tag="acl-migrations"
Usages
You have to use UsersTrait
in your user model.
use Illuminate\Foundation\Auth\User as Authenticatable;
use Junges\ACL\Traits\UsersTrait;
class User extends Authenticatable
{
use UsersTrait;
//
}
Assigning Permission
//by slug
$user->assignPermissions('permission-slug-1', 'permission-slug-2');
//or by ids
$user->assignPermissions(1, 2, 3);
Checking Permissions
// by slug
$user->hasPermission('permission-slug');
//or ids
$user->hasPermission(1);
For more usages example please see their official documentation.
Doc Laravel ACL
Excel data import and export is a common feature in a web application as well as CSV. Maatwebsite Excel laravel package made this task so easy with straight forward some line clean code.
Installation
composer require maatwebsite/excel
Publishing vendor config
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider"
Usages
Export to Excel
public function export()
{
$data = Invice::all();
return Excel::download($data, 'users.xlsx');
}
Import from Excel
<?php
namespace App\Imports;
use App\User;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;
class UsersImport implements ToModel
{
public function model(array $row)
{
return new User([
'name' => $row[0],
'email' => $row[1],
'password' => Hash::make($row[2]),
]);
}
}
public function importFromExcel()
{
Excel::import(new UsersImport, 'users.xlsx');
}
Doing backup is a very important task for a web application but making a backup manager from scratch is not so easy especially if you connect with cloud-like google, dropbox, aws. The laravel backup manager package makes easy the backup task. You can easily integrate the backup system with your web application easily.
Installation
composer require backup-manager/laravel
To support dropbox adapter
composer require srmklive/flysystem-dropbox-v2
Read their doc for the more available adapter.
Usages
protected function schedule(Schedule $schedule) {
$environment = config('app.env');
$schedule->command(
"db:backup --database = mysql --destination=s3 --destinationPath=/{$environment}/projectname --timestamp="Y_m_d_H_i_s" --compression=gzip"
)->twiceDaily(13,21);
}
Doc Laravel Backup
Now in web application facebook, twitter, google, GitHub login system are common to login to the web application. People are comfortable login with their account which they already have like facebook, twitter, google, GitHub etc. To integrate the social authentication system into your application the laravel socialite is the best package.
Installation
composer require laravel/socialite
Usages
In your config/services.php
'github' => [
'client_id' => env('GITHUB_CLIENT_ID'),
'client_secret' => env('GITHUB_CLIENT_SECRET'),
'redirect' => 'http://your-callback-url',
],
...
...
In controller part
<?php
namespace App\Http\Controllers\Auth;
use Socialite;
class LoginController extends Controller
{
public function redirectToProvider()
{
return Socialite::driver('github')->redirect();
}
public function handleProviderCallback()
{
$user = Socialite::driver('github')->user();
$token = $user->token;
}
}
Datatables is a popular jQuery plugin for representing data in a table with some great features like searching, sorting and so on. The laravel data table package helps you to archive datatable functionality in your laravel application.
Installation
composer require yajra/laravel-datatables-oracle:"~9.0"
Usages
public function getData(){
return datatables()->of(User::all())->toJson();
}
If you are not a fan of auto-generated id in your table or wanna generate custom id then laravel id generator is for you. It is simple to use and easy to setup. With the help of this package, you can generate like INV0001, 19110001, P-00001 or any custom format ID.
Installation
composer require haruncpi/laravel-id-generator
Usages
// use within single line code
$id = IdGenerator::generate(['table' => 'todos', 'length' => 7, 'prefix' => 'INV']);
// output: INV0001