laravelarticle / laravel-electron

Making Laravel desktop application using Electron Js
143 stars 67 forks source link

Any idea to make it work in macOS and Linux? #2

Open lfbn opened 4 years ago

lfbn commented 4 years ago

Because of PHP, for what I see this won't work as desktop application outside of Windows.

I was thinking, maybe it can be used, in main.js, instead of the node js PHP package, a copy of a builded PHP like the one extracted by https://php-osx.liip.ch/, if the operating system is macOS or Linux.

After making PHP working, it would be necessary to run the PHP with the built-in server.

I don't know if this will also work after packaging the application.

In short, if we include a standalone PHP copy, and check for the operating system, maybe this would work for all operating systems. Yes?

mtolhuys commented 4 years ago

Hi @lfbn ,

I ran into this too. The following fixed it for me.

In main.js:22 change bin to use the one on your machine:

  phpServer.createServer({
    port: port,
    hostname: host,
    base: `${__dirname}/www/public`,
    keepalive: false,
    open: false,
    bin: '/usr/bin/php',  // <---- this one here
    router: __dirname + '/www/server.php'
  });

I've also set the serverUrl manually to go right to the test route:

const serverUrl = `http://${host}:${port}/`;

Hope this fixes it for you too!

lfbn commented 4 years ago

Hi,

Nice tip.

But what I was thinking was, to have PHP included in the project. This way we don't need to install.

If I had time I will try to do it.

takumade commented 4 years ago

Yeah i was successful after some experimenting it on MAC OS:

https://github.com/blackgeneration/Laravel-Electron-For-MAC-OS.git

The php is contained with the project :)

mintech-dot commented 2 years ago

This will work for Linux :)

https://github.com/mintech-dot/CRUD-Laravel-electronjs/