Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Laravel Schema Rules

Laravel Schema Rules Laravel Package

laracraft-tech/laravel-schema-rules

Laravel Schema Rules automatically generates basic Laravel validation rules from your database table schema, giving you a starting point to fine-tune validation. Install as a dev dependency and generate rules for whole tables or specific columns.

View on GitHub
Deep Wiki
Context7

Laravel Schema Rules automatically generates basic Laravel validation rules by inspecting your database table schema. Instead of writing boilerplate by hand, you get a ready-made starting point to fine-tune and optimize for your application's needs.

  • Whole-table generation — create rule sets for an entire table in one command
  • Column-specific rules — target only the columns you need
  • Form Request generation — scaffold a Form Request class with rules included
  • Skip columns — exclude fields like timestamps via config
  • Multi-driver support — works across supported database drivers
Frequently asked questions about Laravel Schema Rules
How do I install laravel-schema-rules?
Install it as a dev dependency with composer require laracraft-tech/laravel-schema-rules --dev. Optionally publish the config file using php artisan vendor:publish --tag="schema-rules-config" to customize skipped columns. No migrations or production service provider changes are required.
Which Laravel versions does laravel-schema-rules support?
The package is compatible with Laravel 8 through 13 according to its compatibility badge and evaluation notes. It relies on Laravel's schema builder and Artisan commands, so it fits convention-following Laravel apps. Check the Packagist badge for the exact latest supported range before adopting.
How do I generate validation rules for a whole database table?
Run php artisan schema:generate-rules table_name, replacing table_name with your actual table. The command inspects the live schema and prints a PHP array of basic rules you can copy into a Form Request or controller. You need a reachable database connection at generation time.
How can I generate rules for only specific columns?
The schema:generate-rules command supports limiting output to specific columns by naming them alongside the table. This is useful when only part of a table is user-editable. Review the README for the exact argument order for your package version.
Can laravel-schema-rules create a Form Request class for me?
Yes, the package can scaffold a Form Request class using the --create-request or -c flag. You can target a namespace such as Api\V1\StorePersonRequest with --file, so generated requests fit existing app/Http/Requests layouts. Treat the generated class as a starting point and add authorization and business rules manually.
Which database drivers are supported for rule generation?
The package supports MySQL, PostgreSQL, and SQLite, with driver-specific behavior for ranges and lengths. Because output depends on the driver and version used at generation time, generate rules against the same database engine as production where possible. SQLite locally and PostgreSQL in production can produce different min and max values.
Why are decimal and float columns only getting required and numeric rules?
Laravel Schema Rules maps float, decimal, and double columns to ['required', 'numeric'] without precision or scale bounds. The README states this limitation explicitly. For financial or measured values, add decimal, min, max, or between rules manually after generation.
Does it generate unique, exists, or required_if validation rules?
No, it derives rules from column definitions only, so it cannot infer uniqueness, cross-field invariants, conditional requirements, or authorization. Foreign keys become exists:table,id against the connection used during generation, which may need correction for cross-connection or schema-qualified references. Add uniqueness and required_if rules by hand before merging.
Is laravel-schema-rules safe to use in production?
It is designed as dev-only tooling installed with --dev and does not add runtime middleware, service providers, or container bindings. The generated rules are a floor, not a complete validation strategy, so production safety depends on human review for uniqueness, authorization, and business invariants. Avoid pasting production schema DDL into the hosted web equivalent if you handle regulated data.
What happens when I use --force and overwrite generated Form Requests?
The --force flag overwrites existing Form Requests silently, including any hand-tuned rules you added after generation. Since the tool's value comes from post-generation editing, use --force carefully and keep generated requests under version control. Decide whether you commit generated requests and own them or regenerate on demand, and review diffs before merging.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package