Laravel Packages

When starting a new Laravel project, there are a few packages that I install every time. These benefit me in various ways: some provide a better developer experience, whilst others provide useful functionality to my end users. I've neither created nor contributed to any of these packages, I just like them.

My aim is to explain what these packages do for me, and how they benefit my projects. I'd strongly recommend checking out their respective GitHub links (noted in each section), as I often barely touch the surface. If you have any suggestions for other packages, please let me know!

Barryvdh's Laravel Debugbar

Starting off strong, Barry vd. Heuvel's Laravel Debugbar (built ontop of PHP Debug Bar ) allows me to quickly understand inefficiencies or bottlenecks in my application, and where they come from. This package provides a toggleable bar at the bottom of the screen (when in development mode), detailing a request from start to finish.

The models panel shows all loaded models for the current request. I often use this to check new features don't load excessive or unneeded models.

laravel debugbar showing the number of loaded models

The queries panel shows all database queries executed for the current request. This is where I head as soon I notice there are too many models being loaded.

laravel debugbar showing the number of queries

It is also great at catching N+1 problems.

laravel debugbar showing n+1 queries

Spatie Activitylog

Next up is Spatie's Activity Log. This package hooks into model events, logging activities into a database table. This is incredibly useful for debugging, as it provides a clear and concise log of exactly what changed and when.

showing the schema for the laravel activity log table

I personally only log changed attributes, as I find that it helps prevent the database from filling up with repeating, valueless information. I often utilise this table to create some sort of activity feed UI, whether that just be for me - to monitor what's going on, or for the end users.

showing a UI feed for the laravel activity log table

Laravel Pint

Laravel Pint is a first part package built on top of PHP-CS-Fixer, highlighting code that does not fit with a declared standard. It defaults to the opinionated coding style of Laravel, but can be easily customised to meet individual preferences.

Consistent styling of code aids readability, and limits the need for developers to think about personal styling preference.

showing laravel pint fixing some style inconsistencies

Barryvdh Laravel IDE Helper

Laravel 'magic' is an often debated topic. Whether you love it or hate it, when using Laravel it is very likely that some 'magic' is in your project - from anything as complex as facades, to anything as simple as model properties. IDEs often have trouble understanding these areas of the framework. As a result, they may flag up weak warnings or fail to provide autocomplete.

Barry vd. Heuvel's IDE Helper fixes these problems, by generatingPHP doc-blocks . It enhances the developer experience by enabling static analysis and IDE autocompletion to seamlessly integrate with Laravel 'magic'.

showing the lack of autocomplete for eloquent model properties without the IDE Helper
showing the autocomplete for eloquent model properties with the IDE Helper