An easiest way to use php in electron
Switch branches/tags
Nothing to show
Clone or download
Latest commit 0f5c12e Mar 7, 2018

alt text


An easiest way to use php in electron.

  • For now its only supports MAC. And windows and Linux will be supported if php will be installed. I invite openly everyone to contribute in this project and make it working in window and linux also.

Clone and run for a quick way to see Electron4PHP in action.

git clone
npm install
npm start

Use this app along with the Electron API Demos app for API code examples to help you get started.

A basic Electron4PHP application needs just these files:

  • package.json - Points to the app's main file and lists its details and dependencies.
  • main.js - Starts the app and creates a browser window to render HTML. This is the app's main process.
  • index.php - A web page to render. This is the app's renderer process.

To Use

To clone and run this repository you'll need Git and Node.js (which comes with npm) installed on your computer. From your command line:

# Clone this repository
git clone
# Go into the repository
# Install dependencies
npm install
# Run the app
npm start

Note: If you're using Linux Bash for Windows, see this guide or use node from the command prompt.


You can pass a callback to the run method, this will get called when the PHP server is up and running. If you don't pass a callback to the run method, a promise will be returned that resolves when the PHP server is up and running. These you need to do at main.js file from where you find comment of // PHP SERVER CREATION /////


Name Default Description
php php The php command file
host The server's host
port 8000 The port used
directory null The document root. By default is the current working directory
script null The "router" script
stdio inherit stdio option passed to the spawned process -
directives {} An object with the custom PHP directives
config null The path of a custom php.ini file
env process.env The environment variables passed


const PHPServer = require('php-server-manager');

const server = new PHPServer({
    port: 3000,
    directives: {
        display_errors: 0,
        expose_php: 0

Use with gulp

gulp.task('php-server', done => {
    const server = new PHPServer({
        directory: 'public',
        script: 'public/index.php'


CC0 1.0 (Public Domain)

Credits (Thank You)