Web2Executable icon indicating copy to clipboard operation
Web2Executable copied to clipboard

Adding PHP

Open 2braincells2go opened this issue 9 years ago • 25 comments

I know this is not an issue, but can't seem to figure any other way to ask...

Got a little project for upcoming school year. Need to run some basic PHP scripts in a Windows exe (maybe even MAC later). Is there an easy way to do this with Web2Exe? Maybe a good tutorial on the net somewhere you could refer me to?

Thank you much in advance!

2braincells2go avatar Jul 31 '15 15:07 2braincells2go

You could always email, but I don't mind an issue for a question :)

There is a project that does this: https://github.com/baconface/php-webkit/

I just created a pull request to make it work on Mac: https://github.com/baconface/php-webkit/pull/19

I just tested it, and it works! In order to get it to work, clone the repo, change into it's directory and then follow these steps:

  • Install dependencies with npm install
  • Download the php-cgi binary file for windows here and Mac using homebrew
  • Put the php-cgi[.exe] in the ./bin/php/ folder of the php-webkit project
  • Put your index.php app inside the ./application/ folder of the php-webkit project
  • Open up Web2Exe and open up the php-webkit repo folder. Choose your settings, export and run!

If the directions are unclear, let me know. Good luck with your project :)

jyapayne avatar Jul 31 '15 18:07 jyapayne

Works on linux, too!

php-nodewebkit

jyapayne avatar Jul 31 '15 18:07 jyapayne

Thanks Joey, your a champ!

After I posted here, it dawned on me could have used email. What happens when you near 60 years old... The brain cannot retrieve info faster then can type:)

Will give your recommendations a shot in the morning and see what happens.

Cheers!

2braincells2go avatar Jul 31 '15 21:07 2braincells2go

:) No problem Woody, glad to help you out!

jyapayne avatar Jul 31 '15 21:07 jyapayne

Hello Joey. Got side tracked with "life issues" and did not get back to this until now. Starting of school year make-a-me crazy:)

Far from a "npm" wizard. So I understand: Just running Web2Exe will not install the packages I need? Must run the npm install to make work? (on Windows btw).

I tried creating and get message upon startup of completed project:

Error: Cannot find module 'express'

Cannot get v0.2.4b to run at all on Windows 10 so using v0.2.3b if this makes any difference.

Thanks man!

2braincells2go avatar Sep 09 '15 14:09 2braincells2go

:) Yeah, you must run the "npm install" command, which will download the dependencies for php-webkit so that it will run. The error you are receiving is because of this. To install npm, follow this tutorial: http://blog.teamtreehouse.com/install-node-js-npm-windows

As for 0.2.4b not working on Windows 10, I haven't upgraded yet, so I can't test. Is there any error displayed? Or any errors in the error log file?

jyapayne avatar Sep 09 '15 15:09 jyapayne

Thanks Joey, I had already installed npm and got the dependencies downloaded.

I get the app started but it turns to red screen showing:

Error: spawn ./bin/php/php-cgi.exe ENOENT

Guess I better head over to baconface and ask about that.

As for Win 10 & v0.2.4b no error messages, nothing. Simply does not start. Very strange. If you wish I can open a issue so it not get muddled with this.

2braincells2go avatar Sep 09 '15 15:09 2braincells2go

Sure, you can open a separate issue :)

As for the error you are getting now, you have to copy the PHP binary and put it in that folder. Unless you already did that, in which case I'm not sure what's up.

jyapayne avatar Sep 09 '15 15:09 jyapayne

Think I am having issues with Win 10 and Web2Exe. First time I create project works fine, if I make changes and do second export with Web2Exe the output directory is not updated. Shows "making directories" and then "Done Exporting" real fast and no files actually updated.

Will do little experimenting to see if can give you more info when opening new issue.

Thanks again!

2braincells2go avatar Sep 09 '15 15:09 2braincells2go

I think that may be a bug with 0.2.3b, because I remember that issue happening before. When a get a chance, I'll try installing Windows 10 and see if I can find out what's happening.

Cheers!

jyapayne avatar Sep 09 '15 15:09 jyapayne

Any news on the Mac version? I'm getting that EACCES error and it keeps crapping out on my npm install.

KillerSquid avatar Oct 28 '15 04:10 KillerSquid

You could always use my fork, which has the fix.

jyapayne avatar Oct 28 '15 04:10 jyapayne

Well your fork worked but when i launch it via web2executable I get Error: Cannot find module 'express'. Any ideas? I see the declaration in main.js and the package.json file. I tried cd'ing into the dir and running npm install https://www.npmjs.com/package/express but got a whole ton of errors. Sorry for the beginner level questions. Still wrapping my brain around NW and NPM.

Here's my SS - I am root admin, btw: screen shot 2015-10-28 at 12 15 44 pm

KillerSquid avatar Oct 28 '15 18:10 KillerSquid

Hmmm, the correct way to run the command is just npm install, which will install all the requirements defined in the package.json, but you're way should work for that particular requirement. It's weird that you're getting that error if you are the root admin.

Check the permissions of the ~/.npm folder by running

ls -ld ~/.npm

jyapayne avatar Oct 28 '15 18:10 jyapayne

Once you get that install working, it should be smooth sailing, though :) It's working on my Mac with no issues.

jyapayne avatar Oct 28 '15 19:10 jyapayne

You can try running

sudo chown -R macmini ~/.npm

and then try running the npm install command again. That folder should be owned by you anyways, but just in case it's not :)

jyapayne avatar Oct 28 '15 19:10 jyapayne

Okay- that's just weird. I double-checked that I'm root admin, which I am, but my perms were set to 557. I tried the sudo chown method and then ran npm install and got a few warnings but no errors.

Express looks like it's good. Now I'm getting hung up with Error: write EPIPE. When I run with web2executable it just hangs on 'Starting application'.

Didn't know if you knew this was Dan. Just got your email. Thanks again for ALL your help on everything!

KillerSquid avatar Oct 28 '15 19:10 KillerSquid

Yep, I knew it was you :) I always click on the username before I answer to see if it's someone I've talked to before. No worries about the help, glad to help where I can ;)

Hmm, is there any more information in the console of the exported application?

jyapayne avatar Oct 28 '15 19:10 jyapayne

This is from Terminal using just nw then the app location. How do I get the console of the exported app?

2015-10-28 14:24:33.096 node-webkit Helper[2217:620283] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650 2015-10-28 14:24:34.991 node-webkit Helper[2218:620628] Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650 [2216:1028/142437:ERROR:simple_backend_impl.cc(186)] File structure does not match the disk cache backend. [2216:1028/142437:ERROR:simple_backend_impl.cc(402)] Simple Cache Backend: wrong file structure on disk: /Users/macmini/Library/Application Support/php-webkit/Cache [2216:1028/142437:INFO:simple_index_file.cc(397)] Simple Cache Index is being restored from disk. [2216:1028/142437:INFO:CONSOLE(99)] "{"code":"ENOENT","errno":"ENOENT","syscall":"spawn"}", source: /Users/macmini/Dropbox/php-webkit-master/lib/bridge.js (99)

KillerSquid avatar Oct 28 '15 20:10 KillerSquid

Ah, try copying the php-cgi binary into ./bin/php/ inside the php-webkit directory.

jyapayne avatar Oct 28 '15 20:10 jyapayne

I'm sorry man, where do I find the php-cgi binary? I see how to do it in homebrew but that installs it for the system from what I can see.

KillerSquid avatar Oct 28 '15 20:10 KillerSquid

Ah, no worries. When you install it via homebrew, it will usually go into /usr/local/bin/php-cgi, if it's not there, you can see where it is by running

which php-cgi

and then copying that file to ./bin/php/.

jyapayne avatar Oct 28 '15 20:10 jyapayne

Nailed it. You're the awesomeist, bro. Thanks again! Now I gotta stop playing with this and finishing this damn alpha. (I hit 200,000+ lines this morning!)

KillerSquid avatar Oct 28 '15 20:10 KillerSquid

;) Any time, dude.

Get that alpha done!

jyapayne avatar Oct 28 '15 21:10 jyapayne

Please keep this ticket open, or link to it in the readme.md

sapioit avatar Dec 18 '15 12:12 sapioit