Awesome Laravel Packages with Real World Usage

You've seen this lists before, however I always felt that they seem like the author just googled "laravel packages" and tried to squeeze in as many packages as they could in their list, this is not such a list.

These are things I use frequently in the real world (in Kassal.app, BoatFlow, Reflow and even Tjommi).

I also needed a recent blog post so my new website didnt feel so dated (looks in disgust at old WordPress posts converted to MDX via copy-paste e_e).

Packages

barryvdh/laravel-dompdf

It generates PDFs from HTML, one of the few solutions that reliably works and does not produce garbage, the CSS support is only 2010-ish, so forget your flexbox, here lies tables, floats and absolute positioning.

bilfeldt/laravel-http-client-logger

If you need to aggressively log all HTTP requests sent to an API for debugging, this is the easiest "almost-drop-in" solution I have found, I use this to excessively log API calls to invoicing systems in two SaaS apps where there are no fancy stripe event log, nor any fancy PHP SDKs to use.

blade-ui-kit/blade-icons & blade-ui-kit/blade-heroicons

Allows you to use SVG icons easily using either Blade components or @svg("filename"), makes your life easy, I usually stick to HeroIcons, but you can also use Font Awesome & Co.

bugsnag/bugsnag-laravel

It makes the bugsnag work :)

Note, if you are running on Vapor you need to add the following logging channel to your configuration, as Laravel Vapor silently sets your logging channel to "vapor" automatically.

config/logging.php

return [
    // ...
    'vapor' => [
        'driver' => 'stack',
        'channels' => ['stderr', 'bugsnag'],
        'ignore_exceptions' => false,
    ],

   'bugsnag' => [
        'driver' => 'bugsnag',
    ],
    // ...
]

Due to Vapor's serverless nature, bugsnag will not work "out of the box" because it sends error reports asynchronously, so we have to disable that by turning off batch sending in the bugsnag config, this can be done by adding this to your ENV file.

.env.production

BUGSNAG_BATCH_SENDING=false

This info was gathered from this GitHub issue reply from Chris Fidao (The "Servers For Hackers"-guy).

I wish this was listed in the bugsnag documentation, but now you have sophisticated error logging on Vapor :)

league/csv

It... parses CSV files :)

livewire/livewire

The ultimate superpower, allows you to write reactive components using PHP, absolutely a game changer, this is my go-to now, previously it was Vue, but I can get way more stuff done with Livewire.

milon/barcode

I use this to generate EAN Barcodes on Kassal.app, it is pretty reliably and does its job well, what more can you say.

spatie/laravel-activitylog

Allows you to log activities that happened in your application with an easy to remember API, you can attach an activity directly to a model and also link "who" caused the activity.

We use it a ton in Tjommi to log "significant events" that happens in background jobs, deep inside a scraping job, or to know when a command was ran and how many things that command processed.

And since it stores it in the database, you can simply inspect a single table in your DB tool, and when you no longer need the logs, you can truncate the entire thing, no need to make stuff complicated

activity("debugging")
    ->performedOn($model)
    ->causedBy(\Auth::user())
    ->withProperties([
        "ip" => request()->ip(),
        "format" => request()->input("format"),
    ])
    ->log("User generated an export");

spatie/regex

It makes working with Regexes in PHP more ... readable.

return collect(Regex::matchAll("/(\d+\.\d\d kr)\./", $text)->results())
    ->map(fn (MatchResult $matchResult)  =>  $matchResult->groupOr(1, "0"))
    ->map(fn ($number)  =>  NumberParser::parse($number))
    ->values();

spatie/laravel-sitemap

I use this in Kassal.app to generate large Sitemaps on the fly.

Snippet:

class SitemapController extends Controller
{
    // The absolute max size allowed in a sitemap is 50 000 urls (approx 50mb),
    // however lambda response size limit will break at 5 mb, so let's do a sensible number like 1000 instead.
    const SITEMAP_PAGE_SIZE = 1000;

    public function index()
    {
        $sitemapIndex = SitemapIndex::create();

        foreach (range(1, max(ceil(Product::count() / self::SITEMAP_PAGE_SIZE), 1)) as $page) {
            $sitemapIndex->add(route("sitemap.products", ["page" => $page]));
        }

        return $sitemapIndex;
    }

    public function products(int $page)
    {
        $sitemap = Sitemap::create();

        $products = Product::query()
            ->without(["currentPrice"])
            ->select(["id", "updated_at"])
            ->orderBy("id")
            ->simplePaginate(
                perPage: self::SITEMAP_PAGE_SIZE,
                page: $page
            );

        // Product list sitemaps
        foreach ($products as $product) {
            $sitemap->add(
                Url::create(route("products.show", $product))
                    ->setLastModificationDate($product->updated_at)
                    ->setChangeFrequency(Url::CHANGE_FREQUENCY_WEEKLY)
                    ->setPriority(0.1)
                    ->addImage(
                        route("opengraph.product", $product->id)
                    )
            );
        }

        return $sitemap;
    }
}

spatie/schema-org

Fluent API for building Schema.org metadata, which is good for that SEO-juice™.

vinkla/hashids

Allows you to make Ids that are not UUIDs and not incrementing numbers, useful when generating a "publicly viewable" page that links to some internal data, but you don't want to expose how many there are in the system.

barryvdh/laravel-debugbar

It debugs, and is in a bar, its a debug bar c:

wire-elements/modal

LiveWire package that makes it super easy to throw something in a Modal and open it programatically with Livewire events or via the frontend.

wire-elements/spotlight

Livewire package that allows you to make a spotlight-search-esque command palette where you can define actions in PHP and have them triggered from the frontend.

I use this in Reflow.no to easily make "commands" that the user can execute by pressing Command + K (or CTRL + K on Windows) to go to a support case, create a new draft invoice, find a user by search, etc.

The super obvious stuff

  • Laravel Vapor
  • Laravel Nova
  • Laravel Scout (with Meilisearch)
  • Laravel Sail

Closing

Thanks for reading my latest low effort blog post, best case scenario you heard about some new packages, worst case.... well who cares.

ktnxbai.