Favourite Laravel packages I always install

James Mills > Laravel > Favourite Laravel packages I always install

I thought it might be helpful for me to share a handful of packages which I find myself installing whenever I start a new Laravel application. Let me know if there are any missing!

Laravel Debug bar

barryvdh/laravel-debugbar (Github / Packagist)

Probably the first package I install in every Laravel project is the laravel Debug bar by Barry vd. Heuvel. With over 13 million installes I am not the only person who thinks this is an amazing package. You get a bar at the bottom of the browser window which will show you queries, information about the current Route, the currently loaded views, events and the Laravel version and Environment. And that’s just s small list of the things you can use it for.

composer require barryvdh/laravel-debugbar --dev

Laravel Telescope

laravel/telescope (Official Laravel Docs / GitHub / Packagist)

A very powerful ‘telescope’ into everything that your application is doing. I have only recently started to look at this but it’s been a great help for a recent application we have been working on.


Laravel IDE Helper

barryvdh/laravel-ide-helper (GitHub / Packagist)

A no brainer for anyone who uses PHPStorm. It will basically build some meta files fo the IDE to use which will help with all sorts of magic.

composer require --dev barryvdh/laravel-ide-helper
php artisan clear-compiled
php artisan ide-helper:meta
php artisan ide-helper:generate

Laravel Query Detector

beyondcode/laravel-query-detector (GitHub / Packagist)

The Laravel N+1 query detector helps you to increase your application’s performance by reducing the number of queries it executes. This package monitors your queries in real-time, while you develop your application and notify you when you should add eager loading (N+1 queries). (Taken directly from the Readme)

composer require beyondcode/laravel-query-detector --dev
php artisan vendor:publish --provider=BeyondCode\QueryDetector\QueryDetectorServiceProvider

PHP Coding Standards Fixer

friendsofphp/php-cs-fixer (GitHub / Packagist)

I have been a huge fan of PSR-2 for a long time and if you have ever worked on a project with me you know I can be a sucker about PR’s with code style errors/issues. PHPStorm has a build in Code Style fixer and there are a number of other ways you can set up automatic code style fixing but I prefer this method. I tweak a few things in the config so that I can match my own specific style. I have included a .php_cs config file below so you can use this if you wish. I also use the Makefile as a little helper so that I can run make fix from my project root in a terminal.

I highly recommend you make use of this package locally but if you want to look at automating this and other Laravel specific code styles like making sure you are doing things “The Laravel Way’ then Check out Laravel Shift

composer require --dev friendsofphp/php-cs-fixer
make test
make fix

Laravel UUID

jamesmills/eloquent-uuid (GitHub / Packagist)

A Laravel Eloquent Model trait for adding and using a uuid with models. The trait listens to the creating event. It generates a new UUID and saves it in the uuid column on the model.

I personally like adding UUID’s to every entity in my application. There are the odd occurrences which I don’t do this. The main reason is that I find they much nicer to work with when it comes to URL’s and API’s. You can hide the auto-increment ID’s from the public eye and I personally just think they look and work better.

composer require jamesmills/eloquent-uuid

Just add the package and make sure your Entity/Model uses theHasUuidTrait. When you save the model then a UUID will automatically be added.

<?php

namespace App;
use JamesMills\Uuid\HasUuidTrait;

class User extends Eloquent
{
	use HasUuidTrait;
}

Laravel Timezones

jamesmills/laravel-timezone (GitHub / Packagist)

Laravel Timezones package An easy way to set a timezone for a user in your application and then show date/times to them in their local timezone. I think this is pure magic!

I wrote a blog post specifically about the Laravel Timezones package where I go into a little more detail about why and how to use this package.

I don’t install this in every application but I have found that almost all of my applications have needed to show times and dates to a user in their specific timezone so I usually just install it at project setup so I have it there when needed.

composer require jamesmills/laravel-timezone

// This will add a timezone column to your users table.
php artisan migrate

It has a number of helpful features like blade directives

@displayDate($post->created_at)

// 4th July 2018 3:32:am

2 thoughts on “Favourite Laravel packages I always install

  1. Hi James,

    Can you also publish article on laravel eCommerce packages like Bagisto, Aimeos, Avored etc

    1. Hi Saurav,

      I haven’t used any eCommerce packages with Laravel so I don’t think I am qualified to blog about such packages.

      Have a great day,

      James

Leave a Reply

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