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:
- Node.js: Version 18.x or higher Download Node.js
- XAMPP: (or any PHP 8.1+ environment) Download XAMPP
- Composer: Version 2.x or higher Download Composer
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 versionnpm -v
// to check the version of npmnpm install -g npm@latest
// if npm it is not installed, you can install or update it
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, is good to have your projects organize in a folder, for that you can create a folder with the name C:\xampp\htdocs\projects
in the projects
folder you can create your Prisma PHP project and others.
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. After installing Composer, run the following command to check if Composer is installed correctly:
Confirm that PHP is installed and added to the environment variables in your system. To check if PHP is installed correctly, run the following command:
php -v
// to check the PHP version
if you get an error like this:
php is not recognized as an internal or external command
you need to add PHP to the environment variables in your system. To do this, follow the steps below:
- Open the Control Panel
- Click on System and Security
- Click on System
- Click on Advanced system settings
- Click on Environment Variables
- Under System variables, click on Path and then click on Edit
- Click on New and add the path to the PHP folder, for example,
C:\xampp\php
- Click on OK to save the changes
- Open the command prompt and run the command
php -v
to check if PHP is installed correctly
Documentation and Resources
Installation Steps:
npx create-prisma-php-app@latest
You will be asked for the project name, and then if you want to include Tailwind CSS and other features.
✔ Would you like to use Tailwind CSS? … No / Yes
Select "Yes" to include Tailwind CSS in your project.
Install composer dependencies: in the project directory, run the command:
composer install
If you have chosen to install websocket and encounter an error like this:
- Installing react/promise (v3.1.0): Cloning e563d55d16 from cache e563d55d1641de1dea9f5e84f3cccc66d2bfe02c is gone (history was rewritten?)
Install of react/promise failed
Solution:
- Stop the Apache server to make changes safely.
- Go to
php.ini
, search forextension=zip
. If you find;extension=zip
, remove the;
to enable the extension then save changes - Restart Apache to apply the changes.
- Run
composer install
again.
Set your PHP ROOT PATH in ./prisma-php.json
file if you have select the option to install Prisma PHP ORM, else you can skip this step.
phpRootPathExe: "C:\\xampp\\php\\php.exe", // Replace with your PHP path
Run the project
npm run dev
If you get an "Error" like this:
browser-sync : File C:\Users\Username\AppData\Roaming\npm\browser-sync.ps1
cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies
at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ browser-sync start --proxy localhost:3000 --files "public/**/*"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
Solution
Run the following command in PowerShell as an Administrator:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
Or, if you want to bypass the policy for the current session, run the following command:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass