How to add php file in electron?


#1

Hi,

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

With Kind Regards,
Riti


#2

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.


#3

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 http://electron.atom.io/ for building a desktop app.

Clone the Quick Start repository

$ git clone https://github.com/electron/electron-quick-start

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,
Priti


#4

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.


#5

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,
Jacob


#6

Thanks for your help.


#7

This.

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.


#9

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


I hope you got your answer