Prisma PostgreSQL Setup

Configuration Steps

  1. Modify your schema.prisma file to specify PostgreSQL as the database provider.
  2. Edit the .env file with your PostgreSQL database connection details.
  3. Create and apply migrations as necessary.

schema.prisma Configuration

 generator client {
        provider = "prisma-client-js"
    }

    datasource db {
        provider = "postgresql"
        url      = env("DATABASE_URL")
    }

By default Prisma PHP generate the schema.prisma file with PostgreSQL as the provider, And the configuration above is the default configuration for PostgreSQL.

.env Configuration

DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public"

Replace USER, PASSWORD, HOST, PORT, and DATABASE with your actual PostgreSQL database details to ensure a secure and correct connection.

Integrating PostgreSQL with Prisma PHP using XAMPP

To interact with PostgreSQL, you may need to enable the PostgreSQL extension in your XAMPP's PHP configuration.

Enable PostgreSQL Extension

  1. Locate your XAMPP installation directory and find the php.ini file. This is typically found in the php subdirectory.
  2. Open the php.ini file in a text editor.
  3. Search for the line that looks like ;extension=pgsql and ;extension=pdo_pgsql. Remove the semicolon (;) at the beginning of each line to uncomment these lines. It should look like this:
      extension=pgsql
        extension=pdo_pgsql
  4. Save the changes to php.ini and restart your XAMPP server for the changes to take effect.

This step is necessary to enable your PHP applications running on XAMPP to interact with PostgreSQL databases using the native PHP extensions.

Conclusion

You have now successfully integrated PostgreSQL with Prisma PHP in a XAMPP environment. This setup allows you to develop full-stack applications using Prisma as your ORM with PostgreSQL as the database.

Next Step

Go to Prisma Command to migrate your database.