My Top Five Laravel Packages
As a junior developer, I’ve spent a lot of time exploring the Laravel ecosystem, and one thing I’ve learned is that there’s no shortage of tools to make our work easier and more efficient. While I’m still learning, I’d like to share five Laravel packages that I’ve found incredibly helpful. Whether you’re just starting out or looking for inspiration, I hope these recommendations resonate with you!
A Quick Note on Terminology
Before diving into my top five Laravel packages, I want to clear up some terminology. Technically, there’s a difference between bundles and packages in the Laravel ecosystem:
- Bundles are tools developed and maintained by the Laravel core team.
- Packages are usually created by third-party developers to extend Laravel’s functionality.
That said, most developers — including myself — use the term “package” to refer to both. To keep things simple, I’ll do the same in this article. Now, let’s dive into my top five packages for Laravel.
1. Laravel Pint
Laravel Pint is a package to keep you code clean and consistent. It is Laravel’s official code style fixer which helps you enforce coding standards like PSR-12 so that the code is always well formatted and organized.
Installation
By default, Pint is already installed into all new Laravel installations. So there is no need to specifically download it.
Running
To run Pint inside your Laravel project, simply execute the following command from your project route:
./vendor/bin/pint
Documentation
To read more about Pint - click this link
2. Larastan
Larastan is a code analyzer build on top of phpstan which helps finding errors in your application early. It has plenty of options to configure and to adjust how strict the code analysis will be. More on this on a later article.
Installation
To install Larastan, run the following code in your project root directory:
composer require --dev larastan/larastan
Running
To analyze your code, run the following command in your project root directory:
./vendor/bin/phpstan analyze
Documentation
To access the Larastan documentation click this link
3. Laravel Sail
Laravel Sail is a command line interface to interact with the default Docker environment of Laravel. It enables developing with docker, which eliminates the need of setting up a local environment and the best thing is, one does’nt even need to have knowledge of Docker to get started with Laravel Sail.
Installation
To install Sail, run the following command in you project root directory:
composer require laravel/sail --dev
After that, you may want to run the following command to publish the docker-compose.yaml
file.
php artisan sail:install
Start the Environment
In order to run Laravel Sail you need to have Docker installed on your local machine. After that, you can run the following command to start the development environment.
./vendor/bin/sail up
Documentation
If you want to know more about Laravel Sail - click this link
4. Laravel Breeze
Laravel Breeze is a simple starting kit for including Laravel’s authentication features into a new project. It includes login, registration, password reset, email verification and password confirmation. It also includes a simple profile page with basic styling so you’ll have a headstart when starting new projects - Pretty neat!
Installation
Laravel Breeze can be installed while running the laravel new
command to install a new project. I highly recommend installing
Breeze this way and only on new Laravel projects. Installing Breeze into existing projects can cause a couple of issues.
That being said, you can find the commands to install Breeze via the command line below.
composer require laravel/breeze --dev
php artisan breeze:install
After that, in order to utilize Breeze - run php artisan migrate
to add the new tables to your DB.
Documentation
If you want to dig deeper into Breeze and it’s capabilities, click here
5. Laravel Data by Spatie
The Laravel Data package from Spatie enables Data Transfer Objects (DTOs). Instead of passing arrays between different classes and methods - you can use DTOs to make the code more structured. On top of that, the package enables validation of DTOs and several neat functions for DTOs.
Installation
To install the Laravel Data package, run the following command.
composer require spatie/laravel-data
Usage
Below you can find an example of a DTO.
namespace App\DTOs;
use Spatie\LaravelData\Data;
class UserData extends Data
{
public function __construct()
public string $name,
public string $email,
) {}
}
Documentation
Click here to read more about the Laravel Data package.
Conclusion
These packages have made a big difference in how I approach Laravel development, and I hope they can help you too. This list is by no means definitive — there are countless amazing Laravel packages out there — but these are the ones I’ve found the most useful so far.
If you have favorite Laravel packages or tips for a junior developer like me, I’d love to hear from you! In the following weeks, I will dive deeper into a few of these packages and how to make the most out of them.
Happy coding, and see you next time!