Parkman Schema is a powerful Laravel package that generates Laravel migrations and models from Prisma schema files. It simplifies the process of transitioning from Prisma to Laravel by automatically creating the necessary database structure and Eloquent models.
You can install the package via composer:
composer require paulobunga/parkman-schemaTo generate Laravel migrations from your Prisma schema:
use Paulobunga\ParkmanSchema\Parkman;
$parkman = new Parkman();
$parkman->setSchema(file_get_contents('path/to/your/schema.prisma'));
$parkman->generateMigrations();This will create migration files in your Laravel project's database/migrations directory.
To generate Eloquent models from your Prisma schema:
use Paulobunga\ParkmanSchema\Parkman;
$parkman = new Parkman();
$parkman->setSchema(file_get_contents('path/to/your/schema.prisma'));
$parkman->generateModels();This will create model files in your Laravel project's app/Models directory.
The package also provides Artisan commands for easy use:
# Generate everything
php artisan parkman:generate path/to/your/schema.prisma --all
# Generate specific components (migrations are generated by default if no flags)
php artisan parkman:generate path/to/your/schema.prisma --models --controllers
# Individual commands (legacy)
php artisan parkman:generate-migrations path/to/your/schema.prisma
php artisan parkman:generate-models path/to/your/schema.prismaYou can publish the stub files to customize the generated migrations and models:
php artisan vendor:publish --provider="Paulobunga\ParkmanSchema\ParkmanSchemaServiceProvider" --tag="stubs"This will copy the stub files to resources/stubs/vendor/parkman-schema in your Laravel project, where you can modify them to fit your needs.
- Generates Laravel migrations from Prisma schema
- Creates Eloquent models with relationships
- Supports table creation, modification, and deletion
- Handles column additions, removals, and renames
- Manages foreign key constraints
- Automatically reorders migrations based on dependencies
composer testPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email paulobunga.one@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.