Prisma PHP App

Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM

create-prisma-php-app is an innovative command-line tool designed to seamlessly integrate PHP with Prisma ORM. This tool stands out by offering a unique combination of PHP's robust server-side capabilities with Prisma's modern ORM features. Whether you're building a small project or a large-scale application, create-prisma-php-app provides the tools and flexibility needed to elevate your development experience.

Get Started with Prisma PHP

Prerequisites

Ensure your system is equipped with:

After downloading the installer to install the software, open the command prompt and run the following commands to check if the software is installed correctly:

For Node.js

After installing Node.js, run the following commands:

  • node -v // to check the node version
  • npm -v // to check the version of npm
  • npm install -g npm@latest // if npm is not installed

For XAMPP

For XAMPP, it is recommended to install it in the default path C:\xampp. After installing XAMPP, make sure to enable the extension=zip in the php.ini file. This is required to install Composer dependencies.

Create a new Prisma PHP project: in XAMPP C:\xampp\htdocs\ directory, it is good to have your projects organized in a folder. You can create a folder named C:\xampp\htdocs\projects where you can create your Prisma PHP project.

For Composer

While installing Composer, make sure to check the box that says developer mode. This will allow you to set the path to C:\ProgramData\ComposerSetup\bin, which will be used to install Composer globally.

Confirm PHP Installation

Check if PHP is installed and added to environment variables:

php -v

If you get an error like:

php is not recognized as an internal or external command

Follow these steps to fix path issues:

  1. Open the Control Panel
  2. Click on System and Security > System
  3. Click on Advanced system settings > Environment Variables
  4. Under System variables, click on Path and then click on Edit
  5. Click on New and add the path to the PHP folder (e.g., C:\xampp\php)
  6. Click OK to save changes, then restart your command prompt.

Installation Steps

Run the create command:

npx create-prisma-php-app@latest

Interactive Prompt:

✔ Would you like to use Tailwind CSS? … No / Yes

Select "Yes" to include Tailwind CSS.

Install composer dependencies:

In the project directory, run:

composer install

Troubleshooting WebSocket Install

If you encounter the "react/promise failed" error:

- Installing react/promise (v3.1.0): Cloning e563d55d16
from cache... is gone (history was rewritten?)
Install of react/promise failed

Solution:

  1. Stop the Apache server.
  2. Open php.ini and search for extension=zip.
  3. Remove the semicolon ; to enable it.
  4. Restart Apache and run composer install again.

Set PHP Root Path (Optional)

If you selected Prisma PHP ORM, update ./prisma-php.json:

phpRootPathExe: "C:\\xampp\\php\\php.exe", // Replace with your PHP path

Run the project

npm run dev

If you get a "SecurityError" in PowerShell:

browser-sync : File C:\...\browser-sync.ps1 cannot be loaded...
CategoryInfo : SecurityError: (:) [], PSSecurityException
FullyQualifiedErrorId : UnauthorizedAccess

Solution

Run PowerShell as Administrator and execute one of the following:

Option 1 (Permanent for Current User):

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

Option 2 (Current Session Only):

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass