electron-php
electron-php copied to clipboard
Use this electron-php as server (php + mysql)
hello its possible to use electron-php as server like wampserver ? and work with php + mysql ? i want to install to my client as a server on offline mode and work directly on chrome and access to server with http://localhost (link to access to my app)
Hi @AskDesignTeam,
Yes, the steps and code below make it possible.
- Download MariaDB server (mariadb-<version>-winx64.zip) from the official website: https://mariadb.org/download/
- Extract zip file to foundation folder and rename it
- Add the example code below (Add this, line 7 in main.js).
- First time manually run ./mariaDB/bin/mariadb-install-db.exe or ./mariaDB/bin/mysql_install_db.exe (its create data folder)
- Download and use adminer.php for database easy access(recommended)
const { spawn } = require('child_process');
const childProcess = spawn(`${__dirname}/foundation/mariaDB/bin/mysqld.exe`, [], {
detached: true, // Use 'detached' option if you want the child process to continue running even if the parent process exits
stdio: 'ignore' // Use 'ignore' to ignore standard I/O streams (you can customize this as needed)
});
// Optionally, you can listen for events on the child process
childProcess.on('close', (code) => {
console.log(`Child process exited with code ${code}`);
});
childProcess.on('error', (err) => {
console.error(`Child process error: ${err}`);
});
(It may help somebody)
Thanks