Laravel is a great PHP framework, it changed the way we write code by borrowing the best practices from great tools like Symfony, Ruby on Rails and it’s been evolving with lot of best practices on its own.

I love this PHP-based framework more than any other framework as it makes the process of software development easier to implement modules, packages, plugins, and components.

I am Danish Mirza and I’m writing this article to get you through the top Laravel packages to enhance your web application and performance.

5 Best Laravel Packages For Building Laravel Apps

Why do I create this list? My Name is Danish Mirza .I’m a Lazy Developer that’s why  I don’t want to build everything from scratch. And this is where Laravel Packages help me save my time 😉

1. Modules

If You are building a bigger app than Hello Word. Start working with modules.

Keep module entities, controllers, views, routes, configs etc in one place.

Advantages

  • Code encapsulation
  • Order in the code
  • Easier code transfer between apps
  • Code Generation — module, controllers, entities etc.

2. Spatie permissions

Spatie Roles & Permission is one of there best permissions package.

Advantages

  • Roles
  • Permissions
  • Direct Permissions
  • Artisan commands

3. Laravel Datatables

If You use DataTables and you are building yourself javascript, ajax, routes, database queries, filters, search etc. There is an easier solution.

Advantages

  • Easy to use
  • DataTable Service
  • Creates database queries for You
  • Generates Javascript
  • Multiple customisations

4. Easy flash notifications

After saving data from the form I like to redirect the user to list page, edit view or show view. With this package, i can easily notify user about success, warning or error.

Advantages

  • Easy to use
  • Multiple flash options (Success, Error, Warning, Overlay, Modal etc)

5. Laravel Js Validation

I really like this one. Automatic front validation base on request object sound good right? It’s always better to write less code — lazy way.

Advantages

  • Generates Front-End validation base on request obejct.
  • No Javascript coding required
  • Ajax validation supported (Unique, Exists, Custom Validation Rules).

Using Laravel’s Eloquent Efficiently

I’ve seen many cases where Eloquent’s relations and their underlying query builders are not used efficiently. Many of these cases exist because there are multiple paths to the same data, many of which look and feel like equivalent solutions.

The first will go to the database, fetch all posts related to the blog, and create a Collection of models. This is expensive because we have to create and hydrate an instance of every related model.

A good policy is to do as much as possible in the database during the query and as little as possible in PHP, for example where in the database will be much faster than where on a Collection.

One to One Relationship with Example

One to one relationship is one of basic relationships. For example, a User model would be associated with a Address model. To illustrate this relationship, we can create a address() method within the User model and call the hasOne() method to relate the Address model.

One to Many Relationship Example

One-to-many relationship is a relationship where one single model owns the number of the other models. For example, a developer may have many projects.

Many to Many Relationship Example

Each post have many tag and each tag can have many post.To define many to many relationships, we use belongsToMany() method.

Laravel 8.x Auth Example with Jetstream

Laravel 8 has totally changed the auth scaffolding. Latest version of Laravel 8 , in this version laravel uses Laravel’s laravel/jetstream package that provides a quick way to scaffold auth.

Laravel Jetstream

Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management.

First, download the Laravel installer using Composer:

composer global require laravel/installer

now run below command to download a latest laravel 8 application.

laravel new laravel8 –jet

Before we have installed the Laravel Installer, so you may use the –jet option to create a new Jetstream powered Laravel application: Run above command to get new Laravel with jetstream features.

Now in this step we need to migrate our database. So run below command. It will migrates many tables.

php artisan migrate

And finally run below command to compile our js file.

npm install

//then

npm run dev

Now after running php artisan serve command you can visit the root url. Now if you want to disable registration or update password or reset password you can open fortify.php and comment or uncomment the below line of code which features you want include or exclude.

‘features’ => [

        Features::registration(),

        Features::resetPasswords(),

        // Features::emailVerification(),

        Features::updateProfileInformation(),

        Features::updatePasswords(),

        Features::twoFactorAuthentication(),

    ],


Written By:

Danish Mirza

2 thoughts on “Laravel 8 Top Packages

Leave a Reply

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