jaikumar0101/laravel-repo-facade-builder

Laravel package for creating repositories, facades, enums, and other OOP containers using artisan commands

Maintainers

Package info

github.com/Jaikumar0101/laravel-repo-facade-builder

pkg:composer/jaikumar0101/laravel-repo-facade-builder

Statistics

Installs: 21

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

v1.0.2 2026-02-15 04:01 UTC

This package is auto-updated.

Last update: 2026-03-15 04:07:32 UTC


README

A Laravel package that provides convenient Artisan commands for creating repositories, facades, enums, interfaces, and traits with proper namespace support and subfolder handling.

Features

  • 🚀 Repository Pattern: Create repositories with interfaces
  • 🎭 Facades: Generate Laravel facade classes
  • 📋 Enums: Create PHP 8.1+ enum classes with backing types
  • 🔌 Interfaces: Generate interface files
  • 🧩 Traits: Create reusable trait files
  • ⚙️ Services: Generate service classes
  • 📁 Subfolder Support: All commands support nested folder structures
  • Auto-namespace: Automatically handles namespaces based on folder structure

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x or 11.x

Installation

Install the package via Composer:

composer require jaikumar0101/laravel-repo-facade-builder

The service provider will be automatically registered via Laravel's package discovery.

Usage

Make Repository

Create a repository with its interface:

php artisan make:repository User
# or
php artisan make:repo User

This creates:

  • app/Repositories/UserRepositoryInterface.php
  • app/Repositories/UserRepository.php

With subfolders:

php artisan make:repository Accounting/Bill/CreditNote

This creates:

  • app/Repositories/Accounting/Bill/CreditNoteRepositoryInterface.php
  • app/Repositories/Accounting/Bill/CreditNoteRepository.php

Make Facade

Create a Laravel facade:

php artisan make:facade Payment

This creates:

  • app/Facades/Payment.php

With subfolders:

php artisan make:facade Services/Payment

This creates:

  • app/Facades/Services/Payment.php

Make Enum

Create an enum class:

php artisan make:enum Status

With backing type:

php artisan make:enum Status --type=string
php artisan make:enum Priority --type=int

This creates:

  • app/Enums/Status.php

With subfolders:

php artisan make:enum Constants/OrderStatus --type=string

This creates:

  • app/Enums/Constants/OrderStatus.php

Make Interface

Create an interface:

php artisan make:interface PaymentGateway

This creates:

  • app/Interfaces/PaymentGatewayInterface.php

With subfolders:

php artisan make:interface Contracts/Payment/Gateway

This creates:

  • app/Interfaces/Contracts/Payment/GatewayInterface.php

Make Trait

Create a trait:

php artisan make:trait HasUuid

This creates:

  • app/Traits/HasUuid.php

With subfolders:

php artisan make:trait Concerns/HasSlug

This creates:

  • app/Traits/Concerns/HasSlug.php

Make Service

Create a service class:

php artisan make:service User

This creates:

  • app/Services/UserService.php

With subfolders:

php artisan make:service Payment/Stripe/StripePayment

This creates:

  • app/Services/Payment/Stripe/StripePaymentService.php

Examples

Complete Repository Pattern Example

# Create a user repository
php artisan make:repository User

Generated files:

UserRepositoryInterface.php:

<?php

namespace App\Repositories;

interface UserRepositoryInterface
{
    // Methods...
}

UserRepository.php:

<?php

namespace App\Repositories;

class UserRepository implements UserRepositoryInterface
{
    // Implementation...
}

Enum with Backing Type

php artisan make:enum OrderStatus --type=string

Generated file:

<?php

namespace App\Enums;

enum OrderStatus: string
{
    // Define your cases here
    // Example for string enum:
    // case ACTIVE = 'active';
    // case INACTIVE = 'inactive';
}

Facade Example

php artisan make:facade PaymentService

Generated file:

<?php

namespace App\Facades;

use Illuminate\Support\Facades\Facade;

class PaymentService extends Facade
{
    protected static function getFacadeAccessor()
    {
        return 'payment_service';
    }
}

Folder Structure

The package creates files in the following directories:

app/
├── Repositories/     # Repository files
├── Facades/          # Facade files
├── Enums/            # Enum files
├── Interfaces/       # Interface files
├── Traits/           # Trait files
└── Services/         # Service files

Benefits

  • Consistent Structure: Maintains a clean and consistent project structure
  • Time-Saving: Quickly scaffold common OOP patterns
  • Namespace Management: Automatically handles complex namespace hierarchies
  • Best Practices: Follows Laravel and PHP best practices
  • Flexible: Supports any level of folder nesting

Testing

The package includes a comprehensive test suite. To run the tests:

# Install dependencies
composer install

# Run tests
composer test

# Run tests with coverage
composer test-coverage

Running Specific Tests

# Run only repository command tests
vendor/bin/phpunit tests/Commands/MakeRepositoryCommandTest.php

# Run with specific filter
vendor/bin/phpunit --filter it_creates_repository_with_subfolders

Test Coverage

The test suite covers:

  • ✅ Repository creation with interfaces
  • ✅ Facade generation
  • ✅ Enum creation with backing types
  • ✅ Interface generation
  • ✅ Trait creation
  • ✅ Service creation
  • ✅ Subfolder support for all commands
  • ✅ Namespace handling
  • ✅ Directory creation

License

This package is open-sourced software licensed under the MIT license.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Author

Jaikumar0101

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

Changelog

[Unreleased]

Added

  • New make:service command to generate service classes in app/Services/ directory
  • Support for subfolder structures in service generation
  • Comprehensive test coverage for service command