PHPackages                             mphp/laravel-db2form - 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. mphp/laravel-db2form

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

mphp/laravel-db2form
====================

Generate Blade forms and FormRequest classes from DB or JSON schemas!

v1.0.0-beta.5(7mo ago)10MITPHP

Since Oct 17Pushed 7mo agoCompare

[ Source](https://github.com/mbparvezme/laravel-db2form)[ Packagist](https://packagist.org/packages/mphp/laravel-db2form)[ Docs](https://www.mbparvez.me/projects/laravel-db2form)[ RSS](/packages/mphp-laravel-db2form/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

Laravel Database To Form
========================

[](#laravel-database-to-form)

Automatically generate **Blade forms** and **Form request** classes from your database schemas or JSON schema files with `old()` support and built-in CSS styling.

Package Name
------------

[](#package-name)

`laravel-schema-to-form`

Composer: `mbparvez`

GitHub: [mbparvezme](https://github.com/mbparvezme)

Author: [M B Parvez](https://mbparvez.me)

Features
--------

[](#features)

- Generate JSON schemas from database tables.
- Generate Blade forms automatically with:
    - `old()` function for preserving input values
    - `required` attributes
    - Default values
    - Correct input types (`text`, `email`, `checkbox`, `textarea`, etc.)
    - Built-in CSS classes (Bootstrap or custom)
- Generate Laravel **FormRequest** classes with proper validation rules.
- Fully customizable templates for Blade and FormRequest.
- Configurable FormRequest namespace and Blade output directory.

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

[](#installation)

Install via Composer:

```
composer require mphp/laravel-db2form
```

Laravel will auto-discover the package. No extra steps needed to use it.

Commands
--------

[](#commands)

### 1. Generate JSON from DB Tables

[](#1-generate-json-from-db-tables)

```
php artisan form:generate-json
```

Options:

- `--tables=users,posts` → generate JSON only for selected tables
- `--output=custom/path` → save JSON files in a custom folder

### 2. Generate Blade Forms and FormRequest

[](#2-generate-blade-forms-and-formrequest)

```
php artisan form:generate-form
```

Options:

- `--schema=path/to/schema.json` → generate form for a single schema file
- `--output=resources/views/custom_forms` → save Blade files in a custom folder

### 3. Generate JSON + Form Together

[](#3-generate-json--form-together)

```
php artisan form:generate
```

This core command runs both `form:generate-json` and `form:generate-form` in sequence. Use it to generate everything (JSON schemas, Blade forms, and FormRequest classes) at once.

Example Workflow
----------------

[](#example-workflow)

### 1. Generate JSON from database tables:

[](#1-generate-json-from-database-tables)

```
php artisan form:generate-json --tables=users,posts
```

This will create JSON files in `database/form_schemas/`.

### 2. Generate Blade forms and FormRequests from JSON:

[](#2-generate-blade-forms-and-formrequests-from-json)

```
php artisan form:generate-form
```

This will generate:

- Blade files in `resources/views/forms/`
- FormRequest classes in `app/Http/Requests/`
- Input fields automatically include old() values and CSS classes

### 3. Generate Both JSON and Forms in One Step:

[](#3-generate-both-json-and-forms-in-one-step)

```
php artisan form:generate
```

This will automatically:

- Generate JSON schemas from the database
- Generate Blade forms and FormRequests

Publish Templates and Config (Optional)
---------------------------------------

[](#publish-templates-and-config-optional)

Publish templates and config if you want to customize:

```
php artisan vendor:publish --tag=form-schema-templates
php artisan vendor:publish --tag=form-schema-config
```

- Templates: `resources/form-schema-templates`
- Config: `config/form-schema.php`

Configuration
-------------

[](#configuration)

`config/form-schema.php`:

```
return [
    /*
    |----------------------------------------------------------------------
    | FormRequest Namespace
    |----------------------------------------------------------------------
    */
    'request_namespace' => 'App\\Http\\Requests',

    /*
    |----------------------------------------------------------------------
    | Blade Output Path
    |----------------------------------------------------------------------
    */
    'blade_path' => resource_path('views/forms'),

    /*
    |----------------------------------------------------------------------
    | Style Configuration
    |----------------------------------------------------------------------
    | 'style' => 'bootstrap' or 'custom'
    */
    'style' => 'bootstrap', // default style

    'bootstrap_styles' => [
        'form' => 'needs-validation',
        'submit' => 'btn btn-primary',
        'label' => 'form-label',
        'text' => 'form-control',
        'email' => 'form-control',
        'password' => 'form-control',
        'number' => 'form-control',
        'textarea' => 'form-control',
        'select' => 'form-select',
        'checkbox' => 'form-check-input',
        'radio' => 'form-check-input',
    ],

    'custom_styles' => [
        'form' => 'space-y-4',
        'submit' => 'bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700',
        'label' => 'block font-medium mb-1',
        'text' => 'border rounded px-3 py-2 w-full',
        'email' => 'border rounded px-3 py-2 w-full',
        'password' => 'border rounded px-3 py-2 w-full',
        'number' => 'border rounded px-3 py-2 w-full',
        'textarea' => 'border rounded px-3 py-2 w-full',
        'select' => 'border rounded px-3 py-2 w-full',
        'checkbox' => 'rounded text-blue-600 focus:ring-blue-500',
        'radio' => 'text-blue-600 focus:ring-blue-500',
    ],
];
```

Customizing Templates
---------------------

[](#customizing-templates)

After publishing, you can edit:

- `resources/form-schema-templates/form.blade.php.template` → for custom Blade layout
- `resources/form-schema-templates/request.php.template` → for custom FormRequest template

Contribution
------------

[](#contribution)

Contributions are welcome! If you have ideas for improvement, bug fixes, or want to add new features:

1. Fork the repository
2. Create a new branch (`feature/new-feature`)
3. Commit your changes
4. Push to your branch
5. Open a pull request

License
-------

[](#license)

[MIT License](https://github.com/mbparvezme/laravel-db2form?tab=MIT-1-ov-file)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance65

Regular maintenance activity

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 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 ~0 days

Total

5

Last Release

212d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7aa26ef13b61887a14ba03503d5debacb774d60c2ce1cb38db19b6172e3a02c6?d=identicon)[mbparvez](/maintainers/mbparvez)

---

Top Contributors

[![mbparvezme](https://avatars.githubusercontent.com/u/8216116?v=4)](https://github.com/mbparvezme "mbparvezme (24 commits)")

---

Tags

laravellaravel-packagephpphp-libraryphp-packagelaraveldatabasegeneratorbladedbformform generatorformrequestjson to formdatabase to form

### Embed Badge

![Health badge](/badges/mphp-laravel-db2form/health.svg)

```
[![Health](https://phpackages.com/badges/mphp-laravel-db2form/health.svg)](https://phpackages.com/packages/mphp-laravel-db2form)
```

###  Alternatives

[tucker-eric/eloquentfilter

An Eloquent way to filter Eloquent Models

1.8k4.8M26](/packages/tucker-eric-eloquentfilter)[cybercog/laravel-clickhouse

ClickHouse migrations for Laravel

163166.8k](/packages/cybercog-laravel-clickhouse)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[toponepercent/baum

Baum is an implementation of the Nested Set pattern for Eloquent models.

3154.7k](/packages/toponepercent-baum)[webparking/laravel-db-rebuild

A laravel package that allows for quick database rebuilds with presets.

448.8k](/packages/webparking-laravel-db-rebuild)

PHPackages © 2026

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