larsmbergvall/utilities-for-laravel

Some utilities and helpers for use in Laravel projects

Installs: 50

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/larsmbergvall/utilities-for-laravel

v1.0.0 2025-10-23 17:32 UTC

This package is not auto-updated.

Last update: 2026-01-08 16:06:41 UTC


README

This is a collection of some utilities that I personally use when developing Laravel applications. Feel free to use them in your own projects!

Usage

You can publish the action stub with:

php artisan vendor:publish --tag=utilities-for-laravel-stubs

You can publish the config with:

php artisan vendor:publish --tag=utilities-for-laravel-config

What is included?

Make:action command

php artisan make:action CreatePost command that creates an action class * This would create a CreatePostAction.cs - if you don't want the suffix you can disable it in the config file (or change the suffix to something else)

Result class

A Result class inspired by Rusts Result type

        /** @var Result<array, string> $result */
//        $result = Result::ok(['value' => 'foo']);
        $result = Result::err('something went wrong');

        $result->match(
            ok: fn(array $data) => dd($data),
            err: fn(string $error) => dd($error)
        );

//        $data = $result->getValue();
        $error = $result->getErr();