create-prisma-php-app 1.3.9 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -186
- package/composer-websocket.lock +1993 -0
- package/dist/.htaccess +6 -0
- package/dist/index.js +1 -1
- package/dist/prisma-client-php/index.enc +1 -1
- package/dist/settings/bs-config.cjs +2 -0
- package/dist/settings/paths.php +3 -3
- package/dist/settings/restartWebsocket.cjs +53 -0
- package/dist/settings/restart_websocket.bat +30 -0
- package/dist/src/app/js/index.js +1 -4
- package/dist/src/lib/websocket/ConnectionManager.php +39 -0
- package/dist/src/lib/websocket/server.php +19 -0
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Create Prisma PHP App
|
|
2
2
|
|
|
3
3
|
Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM
|
|
4
4
|
|
|
@@ -6,202 +6,23 @@ Prisma-PHP: A Revolutionary Library Bridging PHP with Prisma ORM
|
|
|
6
6
|
|
|
7
7
|
`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.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Interactive
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Ensure your system is equipped with:
|
|
14
|
-
|
|
15
|
-
- Node.js: Version 16.x or higher [Download Node.js](https://nodejs.org/en/download/)
|
|
16
|
-
- XAMPP: (or any PHP 7.4+ environment) [Download XAMPP](https://www.apachefriends.org/download.html)
|
|
17
|
-
- Composer: Version 2.x or higher [Download Composer](https://getcomposer.org/download/)
|
|
18
|
-
|
|
19
|
-
## Verifying Prerequisites
|
|
20
|
-
|
|
21
|
-
To verify your installations, run the following commands in your terminal:
|
|
22
|
-
|
|
23
|
-
- Node.js: `node -v`
|
|
24
|
-
- PHP: `php -v`
|
|
25
|
-
- Composer: `composer --version`
|
|
26
|
-
|
|
27
|
-
## Installation
|
|
28
|
-
|
|
29
|
-
Installation Steps:
|
|
30
|
-
|
|
31
|
-
1. Open your terminal.
|
|
32
|
-
2. Run the command:
|
|
33
|
-
|
|
34
|
-
- Create a new Prisma-PHP project: in the desired directory, run the command:
|
|
11
|
+
You can create a new Prisma-PHP project interactively by running the command:
|
|
35
12
|
|
|
36
13
|
```bash
|
|
37
14
|
npx create-prisma-php-app@latest
|
|
38
15
|
```
|
|
39
16
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
composer install
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
- Set your PHP_ROOT_PATH_EXE in `settings/project-settings.js` file
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
PHP_ROOT_PATH_EXE: "D:\\xampp\\php\\php.exe", // Replace with your PHP path
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## What's Included
|
|
53
|
-
|
|
54
|
-
### Prisma ORM and TypeScript Support
|
|
55
|
-
|
|
56
|
-
- `typescript`: For robust typing and scalability.
|
|
57
|
-
- `@types/node`: Essential Node.js type definitions.
|
|
58
|
-
`ts-node`: To execute TypeScript scripts in a Node.js environment.
|
|
59
|
-
|
|
60
|
-
### PHP and Composer Dependencies
|
|
61
|
-
|
|
62
|
-
- `vlucas/phpdotenv`: Allows your project to load environment variables from a `.env` file, making configuration management easier and more secure.
|
|
63
|
-
- `ramsey/uuid`, `hidehalo/nanoid-php`: Provide robust solutions for generating unique identifiers in your application.
|
|
64
|
-
- `firebase/php-jwt`: Facilitates working with JSON Web Tokens (JWT) for secure authentication.
|
|
65
|
-
|
|
66
|
-
### Tailwind CSS Support (Optional)
|
|
67
|
-
|
|
68
|
-
- `tailwindcss`, `postcss`, `autoprefixer`: Enhance your front-end with Tailwind's utility-first CSS framework.
|
|
69
|
-
|
|
70
|
-
### browser-sync support (Optional)
|
|
71
|
-
|
|
72
|
-
- `browser-sync`: For live reloading and synchronized browser testing.
|
|
73
|
-
|
|
74
|
-
The package will include `browser-sync` for live reloading and synchronized browser testing. This feature is optional and can be removed if not needed.
|
|
75
|
-
|
|
76
|
-
## Usage
|
|
77
|
-
|
|
78
|
-
```bash
|
|
79
|
-
npm run dev
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
If you get an "Error" like this:
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
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
|
|
86
|
-
at https:/go.microsoft.com/fwlink/?LinkID=135170.
|
|
87
|
-
At line:1 char:1
|
|
88
|
-
+ browser-sync start --proxy localhost:3000 --files "public/**/*"
|
|
89
|
-
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
90
|
-
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
|
|
91
|
-
+ FullyQualifiedErrorId : UnauthorizedAccess
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### Solution
|
|
95
|
-
|
|
96
|
-
Run the following command in PowerShell as an administrator:
|
|
17
|
+
You will be asked for the project name, and then if you want to include Tailwind CSS and other features.
|
|
97
18
|
|
|
98
19
|
```bash
|
|
99
|
-
|
|
100
|
-
"OR"
|
|
101
|
-
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
20
|
+
✔ Would you like to use Tailwind CSS? … No / Yes
|
|
102
21
|
```
|
|
103
22
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
| Command | Description |
|
|
107
|
-
| --------------------------- | ------------------------------------------------------------------------------------------------- |
|
|
108
|
-
| `npx prisma init` | Initializes a new Prisma project by creating the necessary configuration files. |
|
|
109
|
-
| `npx prisma migrate dev` | Creates and applies database migrations in a development environment. Also updates Prisma schema. |
|
|
110
|
-
| `npx prisma migrate reset` | Resets the database by dropping all data and applying all migrations from scratch. |
|
|
111
|
-
| `npx prisma migrate deploy` | Applies pending migrations to the database, typically used in a production environment. |
|
|
112
|
-
| `npx prisma db push` | Pushes the Prisma schema state to the database without generating migration files. |
|
|
113
|
-
| `npx prisma db pull` | Updates the Prisma schema by introspecting the database. |
|
|
114
|
-
| `npx prisma generate` | Generates Prisma Client based on the current Prisma schema. |
|
|
115
|
-
| `npx prisma studio` | Opens Prisma Studio, a GUI to view and edit the data in your database. |
|
|
116
|
-
| `npx prisma format` | Formats the Prisma schema file for better readability and consistency. |
|
|
117
|
-
|
|
118
|
-
## PHP Special Commands for Prisma
|
|
119
|
-
|
|
120
|
-
| Command | Description |
|
|
121
|
-
| ------------------------ | ---------------------------------------------- |
|
|
122
|
-
| `npx php generate class` | Generates PHP classes for the database schema. |
|
|
123
|
-
|
|
124
|
-
## Composer Command
|
|
125
|
-
|
|
126
|
-
| Command | Description |
|
|
127
|
-
| --------------------------- | ---------------------------------------------------------------------------------------------------------------- |
|
|
128
|
-
| `composer install` | Installs all PHP dependencies listed in the `composer.json` file. |
|
|
129
|
-
| `composer update` | Updates all PHP dependencies to the latest versions listed in `composer.json`. |
|
|
130
|
-
| `composer dump-autoload` | Regenerates the list of all classes that need to be included in the project (autoload file). |
|
|
131
|
-
| `composer dump-autoload -o` | Optimizes the autoload by generating a more efficient class map, making it faster to load. Ideal for production. |
|
|
132
|
-
|
|
133
|
-
## Example Usage
|
|
134
|
-
|
|
135
|
-
Basic Query Example:
|
|
136
|
-
|
|
137
|
-
```php
|
|
138
|
-
<?php
|
|
139
|
-
require_once __DIR__ . '/../bootstrap.php';
|
|
140
|
-
use App\Classes\Prisma\Prisma;
|
|
141
|
-
|
|
142
|
-
$prisma = new Prisma();
|
|
143
|
-
print_r($prisma->User->findMany());
|
|
144
|
-
?>
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
This code fetches and displays all users from the `User` table.
|
|
148
|
-
|
|
149
|
-
## Project Structure
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
PrismaPHPProject
|
|
153
|
-
├── prisma # Prisma directory
|
|
154
|
-
│ ├── migrations # Database migration files
|
|
155
|
-
│ ├── schema.prisma # Main Prisma schema file
|
|
156
|
-
│ └── seed.js # Database seeding script
|
|
157
|
-
├── public # Publicly accessible files
|
|
158
|
-
│ └── [...]
|
|
159
|
-
├── src # Source code
|
|
160
|
-
│ ├── app # Core application code
|
|
161
|
-
│ │ ├── api # API endpoints and logic
|
|
162
|
-
│ │ ├── assets # Static assets (images, fonts, etc.)
|
|
163
|
-
│ │ ├── css # CSS stylesheets
|
|
164
|
-
│ │ ├── js # JavaScript files
|
|
165
|
-
│ │ ├── favicon # Favicon files
|
|
166
|
-
│ │ ├── index.php # Main application entry point
|
|
167
|
-
│ │ ├── layout.php # Main application layout
|
|
168
|
-
│ │ ├── metadata.php # Metadata for the application
|
|
169
|
-
│ │ ├── not-found.php # 404 page
|
|
170
|
-
│ │ └── [...] # Other application files (/users, /dashboard, etc.)
|
|
171
|
-
│ ├── lib # Utility functions and libraries
|
|
172
|
-
│ └── [...]
|
|
173
|
-
├── settings # Configuration files
|
|
174
|
-
│ ├── bs-config.cjs # BrowserSync configuration
|
|
175
|
-
│ ├── paths.php # Path settings
|
|
176
|
-
│ └── project-settings.js # Project settings **NOTE**: PHP_ROOT_PATH_EXE: "D:\\xampp\\php\\php.exe", Replace with your PHP path
|
|
177
|
-
├── vendor # Composer dependencies
|
|
178
|
-
├── bootstrap.php # Initialization script
|
|
179
|
-
├── .env # Environment variables
|
|
180
|
-
├── composer.json # Composer configuration
|
|
181
|
-
├── composer.lock # Composer lock file
|
|
182
|
-
├── postcss.config.js # PostCSS configuration (Tailwind CSS)
|
|
183
|
-
├── tailwind.config.js # Tailwind CSS configuration
|
|
184
|
-
├── tsconfig.json # TypeScript configuration
|
|
185
|
-
└── [...]
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Documentation and Resources
|
|
189
|
-
|
|
190
|
-
- [Node.js](https://nodejs.org/en/docs/)
|
|
191
|
-
- [XAMPP](https://www.apachefriends.org/index.html)
|
|
192
|
-
- [Composer](https://getcomposer.org/doc/)
|
|
193
|
-
- [Prisma Documentation](https://www.prisma.io/docs/)
|
|
194
|
-
- [PHP Documentation](https://www.php.net/manual/en/)
|
|
195
|
-
- [Tailwind CSS Documentation](https://tailwindcss.com/docs)
|
|
196
|
-
|
|
197
|
-
## VSCODE Extensions
|
|
198
|
-
|
|
199
|
-
For a better development experience, consider installing the following Visual Studio Code extensions:
|
|
23
|
+
Select "Yes" to include Tailwind CSS in your project.
|
|
200
24
|
|
|
201
|
-
|
|
202
|
-
- [PHP Intelephense](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client)
|
|
203
|
-
- [PHP Debug](https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug)
|
|
204
|
-
- [Tailwind CSS IntelliSense](https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss)
|
|
25
|
+
## Complete documentation is available at [Prisma PHP](https://prismaphp.tsnc.tech/) website.
|
|
205
26
|
|
|
206
27
|
## Video Tutorial
|
|
207
28
|
|