PHPackages                             usman/make-services - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. usman/make-services

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

usman/make-services
===================

Comprehensive Laravel package for generating services, repositories, interfaces, actions, DTOs and more with artisan commands

v1.0.0(7mo ago)04MITPHPPHP ^8.0

Since Sep 23Pushed 7mo agoCompare

[ Source](https://github.com/UsmanMalik748/makeservices)[ Packagist](https://packagist.org/packages/usman/make-services)[ Docs](https://github.com/UsmanMalik748/makeservices)[ RSS](/packages/usman-make-services/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (2)Used By (0)

Laravel Developer Toolkit - Make Services &amp; More
====================================================

[](#laravel-developer-toolkit---make-services--more)

[![Latest Version on Packagist](https://camo.githubusercontent.com/aae9ea34fb85e6e5bdea37d9f2629d1ca312b933fcd66a95773eb2f4c10216cf/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75736d616e2f6d616b652d73657276696365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/usman/make-services)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7195f329e764fe8cd99a55860d003cce2b0ebc839ece19003287cc60bfeac6a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f75736d616e6d616c696b2f6d616b652d73657276696365732f72756e2d74657374733f6c6162656c3d7465737473)](https://github.com/UsmanMalik748/make-services/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4ce2cd48cbbe7a138efed0bef3294e1583ca58955c25606ff20fd6872f9dc9d7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f75736d616e2f6d616b652d73657276696365732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/usman/make-services)

A comprehensive Laravel package that provides artisan commands to quickly generate services, repositories, interfaces, actions, DTOs, traits, enums and more in your Laravel application.

✨ Features
----------

[](#-features)

- ✅ **Service Classes** - Generate service classes with optional CRUD methods
- ✅ **Repository Pattern** - Create repositories with model integration
- ✅ **Interface Generation** - Generate interfaces for dependency injection
- ✅ **Action Classes** - Single-purpose action classes (invokable or standard)
- ✅ **Data Transfer Objects** - DTOs with properties and array conversion
- ✅ **Traits** - Reusable trait classes
- ✅ **Enums** - Modern PHP 8.1+ enums with helper methods
- ✅ **Service Stack** - Generate complete stacks (Service + Repository + Interface + DTO)
- ✅ **Nested Folders** - Full support for nested directory structures
- ✅ **Customizable** - Configurable directories, namespaces, and templates
- ✅ **Laravel 9, 10, 11** - Compatible with modern Laravel versions
- ✅ **Professional UX** - Emoji-based success/error messages with file paths

🚀 Installation
--------------

[](#-installation)

Install the package via composer:

```
composer require usman/make-services
```

### Laravel Auto-Discovery

[](#laravel-auto-discovery)

This package supports Laravel's auto-discovery feature, so the service provider will be automatically registered.

### Publish Configuration (Optional)

[](#publish-configuration-optional)

```
php artisan make-services:publish-stubs
```

This will publish:

- `config/make-services.php` - Configuration file
- `resources/stubs/make-services/` - Customizable stub files

📚 Available Commands
--------------------

[](#-available-commands)

### 🔧 Services

[](#-services)

```
# Basic service
php artisan make:services UserService

# Service with CRUD methods
php artisan make:services UserService --crud

# Service with model integration
php artisan make:services UserService --model=User --crud

# Service with interface and repository
php artisan make:services UserService --interface --repository
```

### 🏪 Repositories

[](#-repositories)

```
# Basic repository
php artisan make:repository UserRepository

# Repository with model
php artisan make:repository UserRepository --model=User

# Repository with interface
php artisan make:repository UserRepository --interface
```

### 🔌 Interfaces

[](#-interfaces)

```
# Basic interface
php artisan make:interface UserServiceInterface

# Interface with CRUD methods
php artisan make:interface UserServiceInterface --crud

# Create in Contracts directory
php artisan make:interface UserContract --contract
```

### ⚡ Actions

[](#-actions)

```
# Standard action class
php artisan make:action ProcessPayment

# Invokable action class
php artisan make:action ProcessPayment --invokable
```

### 📦 Data Transfer Objects (DTOs)

[](#-data-transfer-objects-dtos)

```
# Basic DTO
php artisan make:dto UserData

# DTO with properties
php artisan make:dto UserData --properties="name:string,email:string,age:int"

# Readonly DTO (PHP 8.2+)
php artisan make:dto UserData --readonly --properties="name:string,email:string"
```

### 🧩 Traits

[](#-traits)

```
# Generate trait
php artisan make:trait Loggable
```

### 📋 Enums

[](#-enums)

```
# Basic integer enum
php artisan make:enum Status

# String enum with values
php artisan make:enum Status --string --values="pending,approved,rejected"
```

### 🎯 Complete Service Stack

[](#-complete-service-stack)

Generate everything at once:

```
# Complete stack for User
php artisan make:service-stack User --model=User --crud

# This creates:
# - UserService (with CRUD methods)
# - UserRepository (with User model)
# - UserServiceInterface (with CRUD methods)
# - UserRepositoryInterface (with CRUD methods)
# - UserData (DTO)
```

📁 Generated File Structure
--------------------------

[](#-generated-file-structure)

After using the commands, your project structure will look like:

```
app/
├── Services/
│   ├── UserService.php
│   └── Billing/
│       └── InvoiceService.php
├── Repositories/
│   ├── UserRepository.php
│   └── ProductRepository.php
├── Interfaces/
│   ├── UserServiceInterface.php
│   └── UserRepositoryInterface.php
├── Actions/
│   ├── ProcessPayment.php
│   └── SendNotification.php
├── DataTransferObjects/
│   ├── UserData.php
│   └── ProductData.php
├── Traits/
│   └── Loggable.php
└── Enums/
    ├── Status.php
    └── UserRole.php

```

⚙️ Configuration
----------------

[](#️-configuration)

Customize the package by publishing the config file:

```
php artisan make-services:publish-stubs
```

### Available Configurations

[](#available-configurations)

```
// config/make-services.php

return [
    'directories' => [
        'services' => 'app/Services',
        'repositories' => 'app/Repositories',
        'interfaces' => 'app/Interfaces',
        'actions' => 'app/Actions',
        'dto' => 'app/DataTransferObjects',
        'traits' => 'app/Traits',
        'enums' => 'app/Enums',
    ],

    'auto_generate' => [
        'service_interface' => false,
        'repository_interface' => false,
        'service_test' => false,
    ],

    'templates' => [
        'include_crud_methods' => false,
        'include_constructor' => true,
        'include_docblocks' => true,
    ],
];
```

📖 Usage Examples
----------------

[](#-usage-examples)

### Service with Model Integration

[](#service-with-model-integration)

```
php artisan make:services UserService --model=User --crud
```

Generates:

```
