softpulze/laravibe-standards

Standard conventions, structure, and tooling for Laravel apps built the LaraVibe way.

Maintainers

Package info

github.com/softpulze/laravibe-standards

pkg:composer/softpulze/laravibe-standards

Transparency log

Fund package maintenance!

softpulze

Statistics

Installs: 97

Dependents: 0

Suggesters: 0

Stars: 2

Open Issues: 0

v0.3.5 2026-07-27 07:06 UTC

README

Laravibe Standards

Packagist PHP from Packagist Laravel versions GitHub Workflow Status (main) Total Downloads

Standard conventions, structure, and tooling for Laravel apps built the LaraVibe way.

Installation

You can install the package via Composer:

composer require softpulze/laravibe-standards

You may publish all of the package's resources at once:

php artisan vendor:publish --tag="laravibe-standards"

Or, you may publish each resource individually:

Publishing the Configuration File

php artisan vendor:publish --tag="laravibe-standards-config"

Publishing Stubs

php artisan vendor:publish --tag="laravibe-standards-stubs"

Usage

DTOs (Data Transfer Objects)

Laravibe Standards provides a convention for defining immutable, typed DTOs with automatic hydration and serialization.

Generate a DTO:

php artisan make:dto UserProfileDTO
php artisan make:dto Account/UpdateProfileDTO

Define a DTO:

final readonly class UserProfileDTO implements Arrayable, Jsonable
{
    use \SoftPulze\LaravibeStandards\DTOs\Concerns\AsDTO;

    public function __construct(
        public string $name,
        public ?string $bio = null,
    ) {
    }
}

Hydrate and serialize:

$dto = UserProfileDTO::from($request);
$dto = UserProfileDTO::fromArray(['name' => 'Alice', 'bio' => 'Developer']);

$array = $dto->toArray();
$json  = $dto->toJson();
$data  = $dto->toEloquent();

$updated = $dto->with(['bio' => 'Senior Dev']);

See the full DTO guide for conventions, type casting, and advanced usage.

Enums

Laravibe Standards provides a shared HasEnumMetadata trait with label, option, and validation helpers for backed and unit enums.

Generate an enum:

php artisan make:enum ToastType --int
php artisan make:enum ToastType --string

Define an enum:

enum ToastType: int
{
    use \SoftPulze\LaravibeStandards\Enums\Concerns\HasEnumMetadata;

    case Error = 1;
    case Success = 2;
    case Warning = 3;
    case Info = 4;
}

Use helpers:

ToastType::options();    // [{name: 'Error', value: 1, label: 'Error'}, ...]
ToastType::values();     // [1, 2, 3, 4]
ToastType::isValidValue(2);  // true
ToastType::fromValueOrFail(1); // ToastType::Error
ToastType::Error->label();     // 'Error'

See the full enum guide for conventions, the concern contract, and design rules.

Resources

Laravibe Standards provides base resource classes for API and Inertia responses with reusable field helpers.

Generate a resource:

php artisan make:resource UserResource
php artisan make:resource UserCollection --collection

Define a resource:

final class UserResource extends \SoftPulze\LaravibeStandards\Resources\AppResource
{
    public function toArray(Request $request): array
    {
        return [
            $this->id(),
            $this->attribute('name'),
            $this->attribute('email'),
            ...$this->timestamps(),
        ];
    }
}

Use in controllers:

UserResource::make($user);                           // single
UserResource::collection(User::paginate());          // paginated

// Inertia
return inertia('users/Show', ['user' => UserResource::make($user)->toInertia()]);

See the full resource guide for helpers, conventions, and serialization rules.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Thank you for considering contributing to Laravibe Standards! Please review our contributing guide to get started.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

Laravibe Standards is open-sourced software licensed under the MIT license.