PHPackages                             zowesoft/laravel-prisma - 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. zowesoft/laravel-prisma

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

zowesoft/laravel-prisma
=======================

A Laravel wrapper around Prisma — write schema.prisma, run Laravel-style Artisan commands, let Prisma handle the rest.

v1.0.0(3w ago)00MITPHPPHP ^8.1

Since May 18Pushed 3w agoCompare

[ Source](https://github.com/Zowesoft/laravel-prisma)[ Packagist](https://packagist.org/packages/zowesoft/laravel-prisma)[ Docs](https://github.com/Zowesoft/laravel-prisma)[ RSS](/packages/zowesoft-laravel-prisma/feed)WikiDiscussions main Synced 1w ago

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

🔷 Laravel Prisma
================

[](#-laravel-prisma)

A powerful Laravel integration for [Prisma ORM](https://www.prisma.io/) that bridges the gap between Prisma's schema-driven workflows and native Laravel database architectures.

This package allows you to use Prisma's elegant `schema.prisma` file to model your database, while giving you the freedom to choose how those changes are migrated:

1. **Prisma Mode (Default):** Use Prisma's native SQL-based migrations (`prisma/migrations`).
2. **Laravel Mode (Beta):** Generate standard Laravel PHP migration classes (`database/migrations`) directly from your Prisma schema changes!

---

⚠️ Laravel Mode: Under Development (Beta)
-----------------------------------------

[](#️-laravel-mode-under-development-beta)

Warning

**Laravel Mode** is currently in **Beta**. While it is highly capable at translating standard column types, indexes, primary keys, and foreign keys, highly complex database features (e.g. specialized indexes, custom SQLite pragmas, and intricate raw data updates) will fall back to using `DB::unprepared()` raw SQL.

Always review generated PHP migration files before running them in production.

---

How it Works
------------

[](#how-it-works)

```
Your .env (DB_HOST, DB_USER...) ─┐
                                  ├─→ DATABASE_URL built automatically
schema.prisma ────────────────────┘
        │
        ▼
php artisan prisma:generate
        │
        ├───► [Prisma Mode] ──► Runs npx prisma migrate dev (Live output)
        │                       Creates SQL files in prisma/migrations/
        │
        └───► [Laravel Mode] ─► Parses Prisma SQL diffs into Laravel PHP Builders
                                Creates PHP files in database/migrations/

```

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- Laravel 10.x / 11.x / 12.x / 13.x
- **Node.js 18+** (Prisma is a Node.js CLI tool)
- **npm** (or `pnpm`, `yarn`, `bun`)

---

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

[](#installation)

### 1. Install the Laravel Package

[](#1-install-the-laravel-package)

```
composer require Zowesoft/laravel-prisma
```

### 2. Publish the Config (Optional)

[](#2-publish-the-config-optional)

```
php artisan vendor:publish --tag=laravel-prisma-config
```

### 3. Install Prisma &amp; Scaffold Files

[](#3-install-prisma--scaffold-files)

```
php artisan prisma:install
```

This command automatically:

- Checks your system's package manager (`npm`, `pnpm`, `yarn`, or `bun`).
- Installs the Prisma CLI as a dev dependency.
- Scaffolds a `prisma/schema.prisma` pre-configured for your Laravel database.
- Writes a synchronized `DATABASE_URL` to your `.env`.

---

Modes &amp; Configuration
-------------------------

[](#modes--configuration)

You can customize the package behavior in `config/laravel-prisma.php`.

### Switch Migration Modes

[](#switch-migration-modes)

Change the `mode` parameter in your published configuration file or set it in your `.env`:

```
PRISMA_MODE=laravel  # Options: 'prisma' (default) or 'laravel'
```

### Reference Config

[](#reference-config)

```
// config/laravel-prisma.php
return [
    'mode'             => env('PRISMA_MODE', 'prisma'),
    'schema_path'      => base_path('prisma/schema.prisma'),
    'config_path'      => base_path('prisma.config.ts'),
    'migrations_path'  => base_path('prisma/migrations'),
    'package_manager'  => env('PRISMA_PACKAGE_MANAGER', 'npm'),
    'executor_path'    => env('PRISMA_EXECUTOR_PATH', null),
    'node_modules_path'=> base_path('node_modules'),
    'database_url_key' => 'DATABASE_URL',
    'timeout'          => 300,
];
```

---

Migration Workflows
-------------------

[](#migration-workflows)

### 1. Prisma Mode (Default)

[](#1-prisma-mode-default)

In Prisma Mode, Prisma is fully responsible for database migrations. It generates standard SQL files.

1. Make edits to `prisma/schema.prisma`.
2. Generate and apply your migration: ```
    php artisan prisma:generate --name=create_users_table
    ```
3. SQL migration files will be generated in `prisma/migrations/`, and your live database will be updated automatically.

---

### 2. Laravel Mode (Beta)

[](#2-laravel-mode-beta)

In Laravel Mode, Prisma handles the *schema diffing*, but we parse that raw SQL and compile it into a **native Laravel PHP migration**.

Since Prisma is not managing its own migration history files here, it relies on your **live database** to compute what changes still need to be generated.

#### ⚠️ Critical Laravel Mode Workflow Rule:

[](#️-critical-laravel-mode-workflow-rule)

You **must** run your Laravel migrations immediately after generating them. Otherwise, Prisma will still think your database lacks those changes, and your next generation will produce a duplicate, bloated migration!

**The Golden Loop:**

1. Edit `prisma/schema.prisma`.
2. Generate the Laravel migration: ```
    php artisan prisma:generate --name=create_posts_table
    ```
3. **Immediately run Laravel's migrator:**```
    php artisan migrate
    ```
4. Repeat for your next database change!

*Note: The generator checks for duplicate migration names in `database/migrations` and will safely abort to avoid overwriting existing work.*

---

Command Reference
-----------------

[](#command-reference)

CommandDescription`php artisan prisma:install`Installs Prisma dev dependency and scaffolds project configuration`php artisan prisma:init`Regenerates `schema.prisma` using your Laravel configuration`php artisan prisma:generate`Generates a migration (Prisma native SQL or Laravel PHP based on `mode`)`php artisan prisma:generate --name=foo`Generates a migration with a specific, friendly name`php artisan prisma:generate --create-only`Creates a migration without applying it (Prisma Mode only)`php artisan prisma:status`Shows migration history status (Prisma Mode only)`php artisan prisma:reset`Drops all database tables and re-applies migrations (Data-destructive!)`php artisan prisma:validate`Validates `schema.prisma` syntax and schema definitions`php artisan prisma:format`Automatically formats the `schema.prisma` file`php artisan prisma:pull`Pulls database tables and schema and writes them to `schema.prisma``php artisan prisma:prettify`Converts pulled plural snake\_case models to clean singular PascalCase`php artisan prisma:baseline`Baselines an existing database to prevent drift errors`php artisan prisma:baseline --pull`Pulls schema and baselines in a single command`php artisan prisma:push`Directly updates your database schema bypassing migrations (Data-safe for redefines)---

How DATABASE\_URL is Synchronized
---------------------------------

[](#how-database_url-is-synchronized)

The package reads your Laravel `config/database.php` default connection and automatically constructs a valid Prisma connection string:

ConnectionPrisma `DATABASE_URL` Format`mysql`, `mariadb``mysql://user:pass@host:3306/db?charset=utf8mb4``pgsql``postgresql://user:pass@host:5432/db?schema=public``sqlite``file:/path/to/database.sqlite``sqlsrv``sqlserver://host:1433;database=db;user=u;password=p`*Note: Stale `DATABASE_URL` values are automatically ignored and rebuilt during connection changes (e.g. switching between SQLite and MySQL).*

---

Contributing Guide
------------------

[](#contributing-guide)

We welcome contributions to help make `laravel-prisma` more robust, especially in refining the SQL translation parser for Laravel Mode.

### Development Setup

[](#development-setup)

1. **Clone the Repository:**

    ```
    git clone https://github.com/Zowesoft/laravel-prisma.git
    cd laravel-prisma
    ```
2. **Install Dependencies:**

    ```
    composer install
    npm install
    ```
3. **Running the Test Suite:**Ensure you have configured a local database (SQLite is recommended for quick test runs).

    ```
    vendor/bin/phpunit
    ```

### Code Standards &amp; Design Goals

[](#code-standards--design-goals)

- **Maintain PHP Standards:** Adhere to PSR-12 coding style. Run `composer run lint` (or your preferred linter) before pushing code.
- **Fail-safe SQL Parsing:** If adding support for a new database column type or constraint translation in `SqlToSchemaBuilder.php`, make sure it degrades gracefully. Unrecognized syntax must fall back to the safe `DB::unprepared()` wrapper.
- **Maintain Comments and Docstrings:** Make sure your new functions are documented with concise PHP DocBlocks.

### Submitting Pull Requests

[](#submitting-pull-requests)

1. Fork the repository and create a new feature branch (`git checkout -b feature/amazing-feature`).
2. Implement your changes along with corresponding tests.
3. Make sure all PHPUnit tests pass.
4. Commit your changes with semantic, descriptive messages.
5. Submit a pull request to the `main` branch!

---

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance95

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

22d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7b4252ffb8e6587c9b38d9eff586f7a321001b4f16fb08f5d9f78773f8c8de4?d=identicon)[zowesoft](/maintainers/zowesoft)

---

Top Contributors

[![theJohnCode](https://avatars.githubusercontent.com/u/61396088?v=4)](https://github.com/theJohnCode "theJohnCode (18 commits)")

---

Tags

laravelschemadatabaseormmigrationsprisma

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zowesoft-laravel-prisma/health.svg)

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

###  Alternatives

[illuminate/database

The Illuminate Database package.

2.8k54.1M11.0k](/packages/illuminate-database)[spatie/laravel-health

Monitor the health of a Laravel application

87311.3M149](/packages/spatie-laravel-health)[laravel-doctrine/orm

An integration library for Laravel and Doctrine ORM

8455.5M96](/packages/laravel-doctrine-orm)[laravel-doctrine/migrations

Doctrine Migrations for Laravel

782.8M17](/packages/laravel-doctrine-migrations)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

442.1k](/packages/itpathsolutions-dbstan)[orptech/laravel-migration-partition

Laravel extensions that extends Illuminate to enable partitioned table creation within Laravel migrations.

3628.3k](/packages/orptech-laravel-migration-partition)

PHPackages © 2026

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