softpulze / laravibe-standards
Standard conventions, structure, and tooling for Laravel apps built the LaraVibe way.
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/support: ^13.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pao: ^1.0
- laravel/pint: ^1.29
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.6
- pestphp/pest-plugin-laravel: ^4.1
- pestphp/pest-plugin-type-coverage: ^4.0
- phpstan/extension-installer: ^1.4
This package is auto-updated.
Last update: 2026-07-27 07:07:53 UTC
README
Laravibe Standards
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.