PHP code example of zowesoft / laravel-prisma

1. Go to this page and download the library: Download zowesoft/laravel-prisma library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zowesoft / laravel-prisma example snippets


// 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,
];

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/
bash
php artisan vendor:publish --tag=laravel-prisma-config
bash
php artisan prisma:install
bash
   php artisan prisma:generate --name=create_users_table
   
bash
   php artisan prisma:generate --name=create_posts_table
   
bash
   php artisan migrate