Integrate PHP to ElectronJS

0

Greetings community. My question in question comes because I want to start developing a desktop application with ElectronJS, my question is if there is any way to integrate PHP as a programming language or just use NodeJS. If any of you can clarify me about this doubt that I have, I thank you. I have searched for Electron documentation but I still do not know how to integrate it with PHP.

    
asked by Alejo Mendoza 03.12.2017 в 21:48
source

2 answers

0

Unfortunately ElectronJS only allows you to work with Javascript but to personal experience I made an application with Electron and PHP on Windows what I did was:

  • Create an exe project with SMART INSTALL MAKER

  • Configure the installation of an Apache server on a port other than 80, 8080 or 8000

  • Configure PHP installation with Apache.

  • Generate an Electron project to open a window in the Apache server address and port example:

    app.on('ready', function() {  
       mainWindow = new BrowserWindow({width: 800, height: 600});
       mainWindow.loadURL('http://127.0.0.1:5000'); //url del servidor
    
       mainWindow.on('closed', function() {
          mainWindow = null;
       });
    });
    
  • Add all the necessary files to the project, along with installation scripts.

  • Generate the exe for installation in Windows.

The idea is that you can use PHP, if you want to try it you have to have it installed on each machine where your application will be used. Another way is to hire a Hosting that has PHP and have Electron open the url of your site. I hope it helps you.

    
answered by 04.12.2017 / 02:21
source
0

What happens with electron.js is that it allows you to use system features (create files, send notifications, run programs, etc.) through its API, which is accessed by JavaScript. But if you want to use it with PHP, I simply remind you that electron is not more than a browser (simplifying). Therefore, you just have to make a simple script to open the URL where you have the php application running (server or on the same computer).

Ex: link

    
answered by 04.12.2017 в 01:25