What is a Package in Laravel?
Laravel is among the most popular frameworks for web apps and offers a simple and fast development environment. It has packages that let you add more functionality. These packages have routes, controllers, views, and configurations to improve a Laravel application.
Laravel packages let you use different ways of accessing relational databases and perform dependency injections. Currently, we have over 500 Laravel packages that offer all sorts of functionality, from booking and travel to eCommerce and instruction.
Laravel offers two packages: One is framework-independent (stand-alone), and the other is for a specific framework.
One of the primary advantages of using Laravel packages is that they let you access all the framework’s features to its host application, including routing, migrations, tests, views, and numerous other useful features. Also, these packages significantly reduce code repetition via the Don’t Report Yourself (DRY) principle.
This blog lists the best Laravel packages regularly used in Laravel applications.
Best Laravel Packages
Let’s have a look at the best Laravel packages below, which you can use to optimize your application performance.
1. Spatie
Roles and permissions form an important part of many web applications. And Spatie offers you the best permission package to manage roles and permissions. With Spatie, you get the following benefits:
Advantages
- Roles
- Permissions
- Direct Permissions
- Middleware
- Multiple Blade Directives
- Artisan commands
2. Laravel Debugbar
Laravel Debugbar is among the best Laravel packages that help users add a developer toolbar to their application(s). This package is mainly used for debugging purposes .
Debugbar provides you with many options and shows all the queries your application offers. It also displays all the rendered templates and parameters you’ve passed. You can add messages using the Façade (when added), shown under the ‘Messages’ tab in Laravel Debugbar.
- Debugbar::info($object);
- Debugbar::error(‘Error!’);
- Debugbar::warning(‘Watch out…’);
- Debugbar::addMessage(‘Another message’, ‘mylabel’)
3. Laravel User Verification
The Laravel User Verification package allows you to handle user verification and validates email(s).
It generates and stores a verification token for the registered user, sends or queues an email with the verification token link, handles the token verification, and sets the user as verified. This package also provides the verified route middleware functionality.
- public function register(Request $request)
- {
- $this->validator($request->all())->validate();
- $user = $this->create($request->all());
- event(new Registered($user));
- $this->guard()->login($user);
- UserVerification::generate($user);
- UserVerification::send($user, ‘My Custom E-mail Subject’);
- return $this->registered($request, $user)
- ?: redirect($this->redirectPath());
- }
4. Socialite
Socialite offers a simple and easy way to handle OAuth authentication. It allows the users to login 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();
5. Laravel Mix
Formerly known as Laravel Elixir, Laravel Mix provides a clean and rich Application Programming Interface (API) for defining webpack-build steps for your project. It is the most powerful asset compilation tool available for Laravel today.
- mix.js(‘resources/assets/js/app.js’, ‘public/js’)
- .sass(‘resources/assets/sass/app.scss’, ‘public/css’);
6. Eloquent-Sluggable
Slugging is the process of 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
7. Migration Generator
Migration Generator is a Laravel package that allows you to generate migrations from an existing database, including indexes and foreign keys. You can create migrations for all the tables in your database by running the following command:
- php artisan migrate:generate
You can also choose only certain tables that you want to migrate:
- php artisan migrate:generate table1,table2
8 .Laravel Backup
Laravel Backup creates a backup of all your files within an application. It creates a zip file that contains all files in your specified directories, along with a dump of your database.
You can store a backup on any file system. To create a backup, all you need to do is to run the following command:
- php artisan backup:run
9. Entrust
Entrust provides a flexible way to add role-based permissions to your Laravel 5 application. This package creates the following four tables:
- roles table for storing role records
- permissions table for storing permission records
- role_user table for storing one-to-many relations between roles and users
- permission_role table for storing many-to-many relations between roles and permissions.
You can create a role by executing the following lines of code:
- $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();
Let’s check how to assign the roles to the users,
- user = User::where(‘username’, ‘=’, ‘michele’)->first();
- $user->attachRole($admin);
- Now, you must give permissions to these roles:
- $createPost = new Permission();
- $createPost->name = ‘create-post’;
- $createPost->display_name = ‘Create Posts’;
- $createPost->description = ‘create new blog posts’;
- $createPost->save();
- $admin->attachPermission($createPost);
10. No Captcha
No Captcha is a package for implementing Google reCaptcha validation and protecting forms from spamming. It requires you to obtain a free API key from reCaptcha.
- NoCaptcha::shouldReceive(‘verifyResponse’)
- ->once()
- ->andReturn(true);
- $response = $this->json(‘POST’, ‘/register’, [
- ‘g-recaptcha-response’ => ‘1’,
- ‘name’ => ‘Pardeep’,
- ’email’ => ‘[email protected]’,
- ‘password’ => ‘123456’,
- ‘password_confirmation’ => ‘123456’,
- ]);
11. Laravel GraphQL
GraphQL is a data query language that provides an alternative to traditional REST architecture. Besides GraphQL, you can also read more about the Laravel Forge alternative .
This Laravel package helps you set up and use GraphQL in your Laravel apps. Developers use this package to define the required data structure and get the same structure from the server.
Laravel Admin Panel Generator
Admin panel generator has two main groups: visual builders and console-based. The choice depends on your preferences, whether you like to use GUI or prefer typing Artisan commands with parameters.
Also, an important term to remember here is CRUD (Create, Read, Update, Delete) — the core operations that are the building blocks of all admin panels.
12. Voyager: The Missing Laravel Admin
Voyager stands out with a polished and professional interface. This Laravel package offers clear usage instructions, a user-friendly front-end theme, and no apparent bugs or unfinished parts. Voyager offers interesting features, such as dummy-data, media manager, etc.
Voyager offers interesting features, such as dummy-data, media manager, etc.
13.LaraAdmin: Admin Panel + CRM
After installing and logging into your admin panel, the LaraAdmin package allows you to visually create modules representing your CRUDs.
14. Orchid
Orchid works fittingly well for building a business application using the Laravel framework. It acts as a core base for web applications and performs the functions of CMS, CMF, or admin panel for your website.
Laravel Ecommerce Packages
15. Bagisto
Bagisto is an open-source Laravel eCommerce package that caught the Laravel community’s eyes in a very short time. It offers out-of-the-box Laravel user management, multi-warehouse inventory management options, and more.
Also, the Laravel CMS package is bundled with built-in user-friendly admin panel navigation, and offers functionalities like multi-currency, localization, access control level, multi-channel, Payment integration, and much more.
16. AvoRed
AvoRed easily lets you customize the open-source Laravel Shopping Cart as per your needs. It offers a mobile-friendly interface layout by default and is also included among the best Laravel SEO packages.
AvoRed allows you to create product entities like categories, attributes, etc., with efficient order management capabilities for order tracking, customer information, inventory management, and more.
17. Laravel Telescope
Laravel Telescope is an elegant PHP debugger for the Laravel framework. It provides vivid insights into the requests coming onto your application, exceptions, log entries, database queries, notifications, cache operations, and much more. All these insights make Telescope a useful addition to your local Laravel development environment.
Improve Your Laravel App Speed by 300%
Cloudways offers you dedicated servers with SSD storage, custom performance, an optimized stack, and more for 300% faster load times.
Laravel SEO Packages
Laravel Meta Manager
Laravel Meta Manager lets you optimize your website’s SEO, helping your website rank higher on the SERPs. It emphasizes the application’s Meta tags and allows you to correct them following the best SEO practices.
The package comes with recommended Meta tags, including Standard SEO, Dublin Core, Google Plus, Facebook Open Graph, and many others.
SEOTools
SEOTools allows you to optimize your Laravel SEO according to the best SEO practices. It offers excellent website optimization features and is supported by both Laravel and Lumen frameworks.
The package is fairly easy to integrate within the projects, as it has a user-friendly interface that is also beginner-friendly. It also lets you set the titles and Meta tags for both Twitter and Open Graph.
AutoMeta
AutoMeta is an excellent SEO optimization tool for Laravel that helps developers with standard SEO techniques. It is one of the top SEO tools for Laravel, providing easy management of the website’s meta tags. The package also helps fix some common SEO bugs in the application and simplifies crawling for search engine bots.
Laravel Seoable
Laravel Seoable is among the most used SEO packages for Laravel projects. It offers good SEO techniques that fine-tune the Laravel apps for search engine rankings.
This package defines some core Laravel functions following the SEO best practices, such as mapping Eloquent attributes to SEO Meta tags, setting custom templates for page titles/descriptions, defining custom SEO data for application models, and more.
Laravel-SEO
Laravel-SEO is another handy SEO package that allows you to insert, manage, and delete website Meta tags. You can use this package to insert structured data into the Laravel projects and manage some of the most used SEO Meta tags like Facebook Open Graph, Dublin Core, and others effortlessly.
Laravel Package Development Process
When writing Laravel packages, your package won’t have access to all Laravel’s testing helpers. So, if you want to write your package tests as if they existed within a typical Laravel application, you can use the Orchestral Testbench package .
- Setup your Composer.json file for New Package
- Add Service Provider
- Set Alias
- Create a Facade class
These are four important steps that you must know for writing a Laravel package for your speedy development process.
Final Words
This blog has listed the best Laravel packages to help you optimize your project’s productivity.
Choosing the right Laravel package mainly depends upon your project’s requirements. As Laravel provides ease to developers for executing custom-defined operations, you can use these packages to perform functional tasks efficiently.
If you want to recommend more Laravel packages, feel free to share them in the comments below.
Thank you: cloudways
https://www.cloudways.com/blog/best-laravel-packages/#spite