start laravel project inside electron project

Viewed 183

i created a laravel project inside electron js the issue is that first I have to use php artisan serve commad inside the laravel project then only when I start my electron with npm start the laravel project will work how can i over come this issue

what i want is when i start the electron project with npm start the php artisan serve must also work with it

here is a diretory list of my app enter image description here

enter image description here

enter image description here

enter image description here

1 Answers

I followed the documentation your provided here : Laravel desktop application using Electron Js

and everything seems to work pretty well, however you need to know: You don't need to use php artisan serve npm will do all the work for you.

Everything must be in one directory,

  • start by creating a new directory for example: stack

  • inside the stack follow step 1,2 from the documentation you provided.

  • make sure to install php-server :

    npm i --save node-php-server

  • in the step 3 ("Making directories") inside stack create two directories as follow: stack/php : here copy your php folder that contains the bin/php.exe ....etc stack/www : here create your laravel project (Note: make it here, not a sub directory, so it's like stack/www/public , stack/www/artisan ....etc).

  • if you want to edit the directories as you want, pay attention to the following lines in step 4 from the link above:

as a note:

phpServer.createServer({
        port: port,
        hostname: host,
        base: `${__dirname}/www/public`,
        keepalive: false,
        open: false,
        bin: `${__dirname}/php/php.exe`,
        router: __dirname + '/www/server.php'
});
  • base: is the laravel public folder

  • bin : is the bin file to PHP CLI

  • router: is the server.php file from laravel project

Related