PHPackages                             axn/laravel-models-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. [Database &amp; ORM](/categories/database)
4. /
5. axn/laravel-models-generator

ActiveLibrary[Database &amp; ORM](/categories/database)

axn/laravel-models-generator
============================

Eloquent model generation from the database.

8.0.0(1y ago)2315.7k↑132.1%31MITPHPCI passing

Since Sep 8Pushed 1y ago2 watchersCompare

[ Source](https://github.com/AXN-Informatique/laravel-models-generator)[ Packagist](https://packagist.org/packages/axn/laravel-models-generator)[ Docs](https://github.com/AXN-Informatique/laravel-models-generator)[ RSS](/packages/axn-laravel-models-generator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (2)Versions (31)Used By (1)

Laravel Models Generator
========================

[](#laravel-models-generator)

Generates Eloquent models and relations (belongs to, has many, has one) using DB schema.

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

[](#installation)

Install the package with Composer:

```
composer require axn/laravel-models-generator
```

In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider to the array of providers in `config/app.php`:

```
'providers' => [
    // ...
    Axn\ModelsGenerator\ServiceProvider::class,
],
```

Publish config and templates (stubs) if needed using these commands:

```
// config
php artisan vendor:publish --tag=models-generator.config

// stubs
php artisan vendor:publish --tag=models-generator.stubs
```

Config is published in `config/models-generator.php`Templates are published in `resources/stubs/vendor/models-generator/`

Modify config options and templates contents if needed.

Usage
-----

[](#usage)

Simply launch this command:

```
php artisan models:generate

```

**Options :**

- **--table (ou -t) :** if you want to generate only certain tables. To select many tables, you can do: -t table1 -t table2 -t ...
- **--preview (ou -p) :** if you want to only display information messages about actions that will be done by the generator but without touching files.

Naming convention
-----------------

[](#naming-convention)

- **Model:** table name in singular and studly case (cf config "singular\_rules" if singularization is not done correctly).
- **"has many" relation:** name of the related table (plural), in camel case.
- **"has one" relation:** name of the related table (singular), in camel case
- **"belongs to" relation:** foreign key name (without "\_id" or "id\_"), in camel case.

**Other details:**

- **"has many" relation:** the relation name is simply the model name in camel case, so the model name should be in plural.
- **"has many" and "has one" relations:** if the foreign key name is not standard, a precision is concatenated to the relation name like "Via{nomFK}".

Example:

```
// "comments" table
class Comment extends Model
{
    // "belongs to" relation to "users" via "user_id"
    public function user() {}

    // "belongs to" relation to "users" via "updator_id"
    public function updator() {}
}

// "users" table
class User extends Model
{
    // "has many" relation to "comments" via "user_id"
    public function comments() {}

    // "has many" relation to "comments" via "updator_id"
    public function commentsViaUpdatorId() {}
}
```

###  Health Score

45

—

FairBetter than 91% of packages

Maintenance42

Moderate activity, may be stable

Popularity35

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 77.8% 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.

###  Release Activity

Cadence

Every ~120 days

Recently: every ~284 days

Total

30

Last Release

464d ago

Major Versions

3.1.0 → 4.0.02017-11-27

4.1.0 → 5.0.02018-06-05

5.4.0 → 6.0.02019-12-31

6.6.1 → 7.0.02025-03-12

7.0.0 → 8.0.02025-03-26

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1314974?v=4)[Axel Neumann](/maintainers/axn)[@axn](https://github.com/axn)

---

Top Contributors

[![lgtaxn](https://avatars.githubusercontent.com/u/23211553?v=4)](https://github.com/lgtaxn "lgtaxn (70 commits)")[![forxer](https://avatars.githubusercontent.com/u/407917?v=4)](https://github.com/forxer "forxer (20 commits)")

### Embed Badge

![Health badge](/badges/axn-laravel-models-generator/health.svg)

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8465.5M96](/packages/laravel-doctrine-orm)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.2M25](/packages/yajra-laravel-oci8)[lemaur/eloquent-publishing

218.1k1](/packages/lemaur-eloquent-publishing)

PHPackages © 2026

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