How to add php file in electron?



Could anyone tell me please how to add .php file in electron.

With Kind Regards,


You may have to initialize a PHP-capable server within your app.

I would ask yourself whether this is something you have to do. It’s very easy to dynamically build pages in JavaScript these days, so PHP is an option, not a necessity as it once was.


Thank you for your reply. :slight_smile:

I am building a desktop application in which i want to use php.

Followed the steps as mentioned in for building a desktop app.

Clone the Quick Start repository

$ git clone

Go into the repository

$ cd electron-quick-start

Install the dependencies and run

$ npm install && npm start

Gone through above ^ steps, able to build desktop app. But Now, want to add php file.

Could you please tell me the furthers step for using php in electron.

With Kind Regards,


Why? What does PHP give you that JavaScript does not?

Could you please tell me the furthers step for using php in electron.

I can’t because I haven’t done it and I don’t know of anyone who has.


As people have already said, PHP does not really give you anything else, however I can see that if you know PHP very well you might want to use it - but dude, learn js :slight_smile:
If you really were hell bent on using PHP, you would have to set up a local server and use electron to connect to it via localhost. I would not use port 80 - for obvious reasons.
The most simple way to do this (but not the best) would be to run the server as a child process of your electron app. Hope this helps,


Thanks for your help.



I’m a fan of PHP but all you’d be able to do with it is run it as an external shell call like php -f file unless you have a server running and then it’s not really running in electron. So I think it would be of little value really.

Learning to use Node.js / JavaScript is the best answer here really.


You can # use php in electron, get a clone and enjoy php.

I hope you got your answer