High performance PHP workerman/webman with TypeScript react as its ui framework, and for the bundler, we use the lightning fast vite.
This boilerplate uses PHP ^7.2
, Webman 1.4.9
, Node.js ^16
, TypeScript 4.8.4
, React 18.2.0
, React Router 6.4.2
, Vite 3.1.8
Install the required packages & libraries with the following command:
$ composer install
$ npm install
// or you could use pnpm
$ pnpm install
Run the command below to start the php server:
$ php start.php
And finally run this command to start watching changes from react ui:
$ npm run watch
// or you could use pnpm
$ pnpm watch
.
├── app # Webman Main Folder with your usual MVC pattern
│ ├── controller
│ ├── middleware
│ ├── model
│ └── view
│ └── www # Bundled version of React from "views" directory and also the actual "public" path
├── config # Configuration for Webman
├── node_modules # Installed NPM packages
├── process # Webman boilerplate
├── public # Temporary "public" directory, will be processed later by vite
├── runtime # Webman boilerplate
├── support # Webman boilerplate
├── vendor # Installed Composer packages
└── views # React Main Folder, edit your UI here
Modify Dockerfile as you see fit.
Run the following command to create docker image while passing everything in .env
as build-arg:
$ docker build --tag <your-project-name> \
$(for i in `cat .env`; do out+="--build-arg $i " ; done; echo $out;out="") \
.
Run the next command to run the image:
$ docker run --name <your-project-name> \
--publish <your-host-port>:80 \
--tty \
--detach \
<your-project-name>