PHP Commands
Custom Commands for Prisma PHP
PHP Class Generation
Utilize the custom command npx php generate class
to automatically generate PHP classes based on the models defined in your prisma/schema.prisma
file. These classes will be created in the src/lib/prisma/classes
directory, enabling efficient database interactions within your PHP project.
npx php generate class
This command streamlines the process of synchronizing your database schema with your PHP application, ensuring that your PHP classes reflect the latest changes in your Prisma schema.
Project Update with Custom PHP Command
Warning: Executing the npx php update project
command will replace all default Prisma PHP files within the project. This does not include custom-created files. It is strongly recommended to save your project to Git before proceeding to ensure you can review all changes made and features added post-update.
Use the command npx php update project
to update the complete project structure with the latest version. This focused update enhances your project’s functionality and security by ensuring your Prisma PHP structure and dependencies are current.
npx php update project
Employing the npx php update project
command as part of your development workflow ensures your project benefits from the latest features and improvements in the PHP ecosystem, while safeguarding your custom work.
After running the npx php update project
command, you will need to install the Composer dependencies by executing the following command: composer update
. This step ensures that your project has the latest dependencies and is fully updated to the latest version.
Prisma PHP Configuration File Requirement
If your project does not have a prisma-php.json
configuration file, you must create it in the root folder (./prisma-php.json
) to proceed with the update. This file should contain your project's specific configurations, such as:
{
"projectName": "prisma-php-docs",
"projectRootPath": "D:\\xampp\\htdocs\\projects\\prisma-php-docs",
"phpEnvironment": "XAMPP",
"phpRootPathExe": "D:\\xampp\\php\\php.exe",
"phpGenerateClassPath": "src/Lib/Prisma/Classes",
"bsTarget": "http://localhost/projects/prisma-php-docs/",
"bsPathRewrite": {
"^/": "/projects/prisma-php-docs/"
},
"backendOnly": false,
"swaggerDocs": false,
"tailwindcss": true,
"websocket": false,
"prisma": true,
"docker": false,
"version": "1.26.4",
"excludeFiles": [
"./prisma/schema.prisma",
"./.env",
"./src/app/layout.php",
"./tailwind.config.js",
"./src/app/index.php",
"./composer.json"
]
}
The excludeFiles
attribute is optional and allows you to specify default project files that should not be modified by the update command. If your intention is to update everything to default and do not wish to preserve any specific files, set this attribute to an empty array: "excludeFiles": []
. This configuration will ensure that all aspects of your project are updated, including overwriting any existing default files with their latest versions.