Here you will learn how to create Real-Time PHP application with PWA and Electron.
- setup
- decent OS -
linux,macos, maybewindowswill do dockeranddocker-composeinstalled - https://store.docker.com/search?type=edition&offering=community- decent web browser -
chrome,firefox, will experience problems withsafariorinternet-explorer postman- https://www.getpostman.com/
- decent OS -
- other
- github account - https://github.com/
- pusher account - https://pusher.com/
-
backend:cdto directory- rename
database.dist.sqlitetodatabase.sqliteinsideapp/Resources - run
docker-compose upcontainer will makecomposer installand launch built-insymfony server - go to address
http://localhost:8888- you should see some logs
-
frontendcdto directory- run
docker-compose upcontainer will makenpm installand launch webpack dev servernpm run app:start. - go to address
http://localhost:9999- you should see some text - build app:
npm run app:build
Try both of these address - you should see some logs in containers
In case you need to enter these containers, please use:
docker exec -it -u app backend_web_1 bashdocker exec -it -u node frontend_node_1 bash
Do not forget to check container names.
If you not familiar with it, please read https://services.github.com/on-demand/paths/electron/starting-with-electron/outline.html
We prepared frontend_node_1 container so it can build electron app for Linux (Ubuntu) platform ,
just run npm run forge:package inside of frontend_node_1 container.
After it's done, look for binaries inside frontend/out folder.
If You want to preview Electron app, only host build option from below can provide npm run forge:start command.
Simply because docker does not have GTK or Display
In case your OS is other than Ubuntu, these are the options we provide:
-
special container:
- go to
frontend/multiplatform-buildand rundocker compose up - in another terminal run
docker exec -it -u app multiplatformbuild_node_1 bash - now you can build package for
Windows,Linux,Macsystems:npm run builder:winnpm run builder:linuxnpm run builder:mac
- go to
-
host build:
- in your Windows/Mac, you should install
nodeand runnpm installinside offrontendfolder - now run
npm run forge:packageand look for binary insidefrontend/appfolder.
- in your Windows/Mac, you should install
We will use manifest.json and ngrok to allow native look from smart phone
- download and extract
ngrok- https://ngrok.com/download - run
ngrok http 9999- you will get world visible url to yourfrontendcontainer - do not forget to run
ngrok http 8888- you will get world visible url to yourbackendcontainer - change
BACKEND_HOSTinsidefrontend/src/main/config.jstongrokurl pointing tobackendcontainer - create
manifest.jsonand follow instruction in https://developers.google.com/web/fundamentals/web-app-manifest/ - go with your mobile browser to
frontendworld visible url, from settings you should be able to chooseadd to home screen - launch the app from home screen.