electron-php icon indicating copy to clipboard operation
electron-php copied to clipboard

Use this electron-php as server (php + mysql)

Open AskDesignTeam opened this issue 2 years ago • 1 comments

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)

AskDesignTeam avatar Oct 22 '22 16:10 AskDesignTeam

Hi @AskDesignTeam,

Yes, the steps and code below make it possible.

  1. Download MariaDB server (mariadb-<version>-winx64.zip) from the official website: https://mariadb.org/download/
  2. Extract zip file to foundation folder and rename it
  3. Add the example code below (Add this, line 7 in main.js).
  4. First time manually run ./mariaDB/bin/mariadb-install-db.exe or ./mariaDB/bin/mysql_install_db.exe (its create data folder)
  5. 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

virtualheart avatar Nov 08 '23 15:11 virtualheart