PHPackages                             bfg/scaffold - 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. bfg/scaffold

ActiveLibrary

bfg/scaffold
============

Scaffolding for recursively creating migration models and relationships between them

1.12.0(4y ago)16801MITPHPPHP ^8.0

Since May 21Pushed 4y ago2 watchersCompare

[ Source](https://github.com/bfg-s/scaffold)[ Packagist](https://packagist.org/packages/bfg/scaffold)[ Docs](https://github.com/bfg/scaffold)[ RSS](/packages/bfg-scaffold/feed)WikiDiscussions master Synced 1mo ago

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

Scaffold package
================

[](#scaffold-package)

The essence of the package is to design a database and initial data in a visual syntax for further processing it and forming layers for working with laravel.

More details
------------

[](#more-details)

A package for creating laravel layers according to a single syntax that is based in a simple array representing a set of rules and conditions that are necessary to build the initial data of the project architecture. We are talking about things like: `Models`, `Model Constants`, `Model Relations`, `Model Properties`, `Model Behaviors (Traits)`, `Casts`, `Migrations`, `Observers`, `Requests`, `Resources`, `Rules`, `Factories`, `Seeders`

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

[](#installation)

You can install the library using composer:

```
composer require bfg/scaffold
```

Beginning of work
-----------------

[](#beginning-of-work)

If the file `/database/scaffolds.json` does not exist, then after the first run of the command` php artisan scaffold` this file will be created automatically! Then you need to fill it with data for generation and re-run the command `php artisan scaffold`.

JSON syntax
-----------

[](#json-syntax)

First, you need to understand how to design an array of scaffolding for your project.

> It is important that you definitely need to understand the whole project in order to make the most correct design of your project and database in one place.

Let's consider a simple design method, this is a `JSON` file.

> This approach is simplified for easy integration and fast implementation.

Simple example of preschool database structure:

```
{
  "required": ["user/location"],
  "commentary": {
    "prop:translatable": ["name"],
    "const:title": "Comments",
    "type": "morphMany:commentable",
    "fields": [
      ["name", ["nullable"]],
      ["src", ["nullable"]],
      "active"
    ],
    "rules": {
      "name": "required|string|min:10|max:191",
      "src": "nullable|string|Uppercase"
    },
    "factory": {
      "name": "faker.unique().name()",
      "src": "faker.imageUrl(640, 480, 'animals', true)"
    },
    "seed": "factory:30,50"
  },
  "rules": {
    "const:title": "Rules",
    "fields": ["title", "text", "active"],
    "relations": {
      "commentary": {}
    },
    "seed": [
      {
        "title": "Warning 1",
        "text": "Warning text 1"
      },
      {
        "title": "Warning 2",
        "text": "Warning text 2"
      }
    ]
  },
  "director": {
    "const:title": "Directors",
    "auth": true,
    "traits": ["Notifiable", "SoftDeletes", "Getter", "Setter", "Scope"],
    "fields": ["name", "last_name", "active"],
    "relations": {
      "commentary": {},
      "reward:hasMany": {
        "const:title": "Rewards",
        "fields": ["name", "license", "photo", "handed_over_at", "active"]
      }
    },
    "seed": {
      "name": "Name",
      "last_name": "Last Name"
    }
  },
  "school": {
    "const:title": "Schools",
    "traits": ["Getter", "Setter", "Scope", "Wets"],
    "fields": ["name", "description", "active", "active"],
    "relations": {
      "director": {},
      "commentary": {},
      "group:hasMany": {
        "const:title": "Groups",
        "fields": ["name", ["slogan", ["nullable"]], "active"],
        "relations": {
          "commentary": {},
          "educator:belongsToMany": {
            "const:title": "Educators",
            "fields": ["name", "last_name", "active"],
            "relations": {
              "commentary": {}
            }
          }
        }
      },
      "service:belongsToMany": {
        "const:title": "Services",
        "fields": ["name", "amount", "description", "active"],
        "relations": {
          "commentary": {}
        }
      },
      "tags:belongsToMany": {
        "const:title": "Tags",
        "fields": ["name", "active", "is_new", "mark_at"]
      }
    }
  }
}
```

For publish this demo:

```
php artisan vendor:publish --tag=scaffold-demo
```

### Now in detail about the array

[](#now-in-detail-about-the-array)

```
{
  "{Singular model name}": { //All fields except names are optional
    "const:{Constant name}": "Constant value", //optional
    "created": false, // Cancel created at support
    "updated": false, // Cancel updated at support
    "path": "app/Models", //by default
    "prop:translatable": ["title"], //For make custom model property
    "namespace": "App\\Models", //by default
    "foreign": "id", //by default
    "observer": [], //observer for model, if the array of values is empty, add all possible events. or list what events are needed in an array.
    "timestamps": true, //by default
    "traits": ["Getter", "Setter", "Scope", "Wets"], //Injected traits. optional
    "type": "{Type name}:{Type parameters}", //The parent type when adding this model as a link. by default hasOne.
    "fields": [ //optional
      ["{Field name}", "Field param",{"Field methods": "Field properties"}],
      ["src", ["nullable"]],
      ["bet", "float", 8, 2, {"default": "0.01", "cast": "string"}],
      ["href", {"cast": "Href"}], //If Cast is specified with a capital letter, scaffolding will consider it necessary to create a custom class for casting.
      "amount" //by default this field is: ['float', 8, 2]
    ],
    "relations": {
      //The name of the relationship can also be plural, in which case it will find or create a model.
      "{Relation name}{:Relation type name (optional)}": {
        //...new model data, or empty object if model exists
      },
      "tags:belongsToMany": {
        "const:title": "Tags",
        "fields": ["name", "active", "is_new", "mark_at"]
      },
      "rewards": {},
      "rewards": {
        //Relation configure api
        "uncascade": true // Switch off all cascade set
        "cascade_update": true // Switcher for cascade update
        "cascade_delete": true // Switcher for cascade delete
        "method": "custom_name" // The relation of method name
        "nullable": false // Set nullable relation / or use "?" before relation name
        "field": "reward_id" // The relation field name
        "related": "hasOne" // Specify the opposite relation manually
      }
    },
    "rules": { // For create model request
      "name": "required|string|min:10|max:191", // Rules of model request
      "src": "nullable|string|Uppercase" // In order to create a custom rule, write the name of the class with a capital letter and it will be created.
    },
    "resource": [], //To create a resource {model_name}Resource
    "resource": ["AdminRules"], //To create multiple resources
    "factory": { // For generate of Fabrica
      "name": "\\faker.unique().name()",
      "src": "\\faker.imageUrl(640, 480, 'animals', true)",
      "time_at": "\\now()",
      "active": "\\rand(0,1)",
      "status": "wait",
    },
    "seed": "factory:30,50", // For add factory to seed you must add this string, for generating 30 to 50 records
    "seed": "factory:30", // To generate 30 records
    "seed": "factory", // To generate 1 record
  }
}

```

Configs
-------

[](#configs)

For publish config:

```
php artisan vendor:publish --tag=scaffold
```

All properties are documented in a file that were published in the `/config/scaffold.php` file.

Clear the generated data from the application.
----------------------------------------------

[](#clear-the-generated-data-from-the-application)

In order to clear constantly regenerated data from your application, run the command `php artisan scaffold:clear`.

In order to delete all the files that created the scaffolding altogether, add the `-a` or `--all` flag to the command `php artisan scaffold:clear -a`.

More flexible `php` api
-----------------------

[](#more-flexible-php-api)

### Blanc adding

[](#blanc-adding)

#### Adding named blanc:

[](#adding-named-blanc)

```
\Bfg\Scaffold\ScaffoldConstruct::namedBlanc("user/location", [
    "location" => [
        "fields" => [
            'lat', 'lon'
        ]
    ],
    "user" => [
        "relations" => [
            "location" => []
        ]
    ]
]);
```

#### Adding blanc in to stream:

[](#adding-blanc-in-to-stream)

```
\Bfg\Scaffold\ScaffoldConstruct::blanc([
    "location" => [
        "fields" => [
            'lat', 'lon'
        ]
    ],
    "user" => [
        "relations" => [
            "location" => []
        ]
    ]
]);
```

### Command adding

[](#command-adding)

#### Adding command:

[](#adding-command)

```
// Example of default command
\Bfg\Scaffold\ScaffoldConstruct::command(
    'required',
    [\Bfg\Scaffold\ScaffoldCommands::class, 'required']
);
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity69

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~9 days

Total

38

Last Release

1464d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/59b2d162a30938ac2c3c56340ebea07a6778a3e1c86cb70b5bc28b69a1c3f04d?d=identicon)[bfg](/maintainers/bfg)

---

Top Contributors

[![Xsaven](https://avatars.githubusercontent.com/u/1726771?v=4)](https://github.com/Xsaven "Xsaven (93 commits)")

---

Tags

laravel

### Embed Badge

![Health badge](/badges/bfg-scaffold/health.svg)

```
[![Health](https://phpackages.com/badges/bfg-scaffold/health.svg)](https://phpackages.com/packages/bfg-scaffold)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3691.5k](/packages/codewithdennis-larament)

PHPackages © 2026

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