PHPackages                             timehunter/laravel-api-module-generator - 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. [API Development](/categories/api)
4. /
5. timehunter/laravel-api-module-generator

ActiveLibrary[API Development](/categories/api)

timehunter/laravel-api-module-generator
=======================================

A simple laravel api module service generator to provide you with a clean and lightweight code structure.

9393PHP

Since Dec 15Pushed 7y ago2 watchersCompare

[ Source](https://github.com/RyanDaDeng/laravel-api-module-generator)[ Packagist](https://packagist.org/packages/timehunter/laravel-api-module-generator)[ RSS](/packages/timehunter-laravel-api-module-generator/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (3)Used By (0)

Laravel Api Module Generator
============================

[](#laravel-api-module-generator)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fc94c8441bfcf0bb00acb1b3a9d76f0fa95b2a7fc0ac8e06dad9bb20d4b7888d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696d6568756e7465722f6c61726176656c2d6170692d6d6f64756c652d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timehunter/laravel-api-module-generator)[![Total Downloads](https://camo.githubusercontent.com/e530ce3f49deb0b1abf23f9ac55f835983b46ccead3637a4403a4c5bea95e449/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74696d6568756e7465722f6c61726176656c2d6170692d6d6f64756c652d67656e657261746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timehunter/laravel-api-module-generator)

IMPORTANT UPDATE
----------------

[](#important-update)

This project is not finished yet, its still missing a lot features. However, you can still use it if you just want a simple structure. I will slowly update the project in the following days.

---

This is a lightweight module-based boilerplate generator.

Please be mind, if you have any issues related to this package, please submit tickets I will only update if there is bugs.

DESCRIPTION
-----------

[](#description)

A simple laravel api module service generator to provide you with a clean and lightweight code structure.

It's just simple and NO other third party helper code.

IMPORTANT: This package is not aimed at setting up a module, this is only for you to quickly create a structure and make it as your own starting point.

Demo
----

[](#demo)

(The Demo might be slightly different to your actual result)

[![](https://github.com/RyanDaDeng/design-patterns/raw/master/apimodule.gif)](https://github.com/RyanDaDeng/design-patterns/blob/master/apimodule.gif)

```
|-- Module
    |-- Contracts
    |-- Controllers
        |--  Api
            |--  V1
        |--  Web
    |-- Facades
    |-- Models
    |-- Providers
    |-- Repositories
    |-- Requests
    	|--  Api
            |--  V1
        |--  Web
    |-- Services
    |-- routes

```

Installation
------------

[](#installation)

- Laravel &gt; 5.4

Via Composer, put it into composer require-dev list, its not needed for production

```
$ composer require timehunter/laravel-api-module-generator --dev
```

Publish config

```
php artisan vendor:publish --provider="TimeHunter\LaravelApiModuleGenerator\LaravelApiModuleGeneratorServiceProvider"
```

Usage
-----

[](#usage)

Step 1 - make up your own config - laravelapimodulegenerator.php in config folder

Step 2 - run command:

```
php artisan laravel-api-module:make
```

Step 3 - add your service provider and facade from generated folder

Step 4 - run command to see registered routes

```
php artisan route:list
```

Step 5: Play with your module

About Folder Structure
----------------------

[](#about-folder-structure)

I try to make the structure as small as possible, there can be many extensions possibly added in. However, people usually has their own habit to create their own structure.

You can also check [laravel-file-generator](https://github.com/RyanDaDeng/laravel-file-generator) project to create your own structure if you want.

### Repository-Service Pattern vs Laravel Eloquent

[](#repository-service-pattern-vs-laravel-eloquent)

There is a debate about whether to implement the repository-service pattern in laravel or not...well, after reading a bunch of blogs, articles and my years' experiences, I can surely tell you Laravel is not designed for using PURE repository-service pattern like Java/Spring.

One big concern is that, Eloquent model uses Active Record which is completely different from Data Mapper. If you are still deciding to make PURE repository-service pattern in Laravel, you will end up with a nightmare, massive, duplicate and ugly code as you are re-writing Eloquent model again.

However, this package still generates a Repository folder that is simply just a query collection, nothing else. I do still prefer you put all your Eloquent-like queries into one single class, it's not about technical SOLD principle levels, its only about code reusability and arrangement.

You can google and read blogs from online, there are some open-source projects available that people try to apply repository-service pattern in Laravel...yeah, very complicated and...my question was like why do you use Laravel in the first place..?

Sometimes you might do CACHE on your queries, you can check Decorator design pattern to help you set up.

### Facade Service

[](#facade-service)

The Facade service is one of powerful Laravel features. (note: Laravel's Facade class is not standard Facade design pattern as we knew).

The sturcture takes repositories(query collection) as paramters, so all you have to do is that put all your business logic in the Service class. Also, all your queires go to Repository. You might notice that there is an interface attached to Service, this is only easier for you to quickly generate service functions, you can remove it if you want.

One endpoint by default would be mapped with one service function right now.

### Models

[](#models)

As the structure is module-based, I prefer you bind $table and $connection for every models in each module folder.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

License
-------

[](#license)

license. Please see the [license file](license.md) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23565942?v=4)[timehunter](/maintainers/timehunter)[@Timehunter](https://github.com/Timehunter)

---

Top Contributors

[![RyanDaDeng](https://avatars.githubusercontent.com/u/37111049?v=4)](https://github.com/RyanDaDeng "RyanDaDeng (60 commits)")

---

Tags

laravel-api-generatorlaravel-crudlaravel-crud-generatorlaravel-makerlaravel-module-generatorlaravel-service-generator

### Embed Badge

![Health badge](/badges/timehunter-laravel-api-module-generator/health.svg)

```
[![Health](https://phpackages.com/badges/timehunter-laravel-api-module-generator/health.svg)](https://phpackages.com/packages/timehunter-laravel-api-module-generator)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
