New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PHP app #1484
Comments
I don't think it is the purpose of Electron. |
Well, I don't think a point in creating an Electron App in PHP. I mean, I create apps in Javascript for Electron and in PHP for Servers. |
There is no support of PHP in Electron. |
It would be nice if php was a thing here, but it would be all the more difficult because of servers. There are many js things for it though. I will try to find a MySQL script. |
@Cheapskate01 PHP wasn't built for this purpose and it would be abuse of it to use in this way. We must try to learn new languages instead of abusing existing ones. Node can do everything php can and is more suitable for an electron like use-case where we need to do async stuff and we just can't afford to block the event loop. If you are new to node, I would suggest you have a look at this cheatsheet and for MySQL You can use node-mariasql or for a nicer API mariasql-promise. |
Not yet, but I'm sure i can find a way if i try On Mon, Oct 26, 2015 at 9:57 AM, gbaumgart notifications@github.com wrote:
|
Hi everybody, i've embed php in electron is someone is interesting |
Looks great! On Wed, Feb 17, 2016 at 7:05 AM, guillaume23 notifications@github.com
|
I have embedded it in an NW.js example as posted on https://github.com/baconface/php-webkit and I recently embedded it into Electron when I converted my editor at https://github.com/baconface/tweaked so I know it is possible. Give me a few days and I convert my NW.js example to Electron when I get a chance. |
@baconface You ever get any where with this? Got a classroom project that really like to try out. |
I ended up using an iFrame to a remote server for stuff like login and register forms that require sql |
@Cheapskate01 yes that is great solution, wish could use but classroom project cannot access the internet. no need for sql on this one... |
Ah. Well, the other (less secure) solution I found is to make everything in On Thu, May 12, 2016 at 9:14 AM, Woody notifications@github.com wrote:
|
It seems like the usual (and secure) way to solve your problem is to provide an API on your server (maybe written in PHP) and use your Electron-app to display a dedicated interface to your server side services. |
I can honestly say I have no clue how to do that. Though it is a good idea. On Thu, May 12, 2016 at 9:29 AM, Florian Breisch notifications@github.com
|
Thanks all of input. Since this is for use in classroom environment where we are "testing & learning", not worried about security at this point. Just something to "try & learn" from mistakes... |
Yeah, well for what you need it for, A localhost server is a good idea. On Thu, May 12, 2016 at 9:57 AM, Woody notifications@github.com wrote:
|
@Cheapskate01 already have a local server, what computer lab would not have one? The point in asking about PHP and Electron was to "hack around" and allow everyone to learn Electron in other aspects. Student brought the subject of PHP and Electron, so my job to explore:) Thanks for your input. |
Alright, no problemo On Thu, May 12, 2016 at 11:23 AM, Woody notifications@github.com wrote:
|
@Cheapskate01 and @2braincells2go like other people said, Electron is only javascript friendly, why would you try enabling PHP server to work in simple app, that makes no sense. Read about API's creation in PHP, and then connect electron to your API. Simply output given API data in APP and that's it. |
@andrejuseu i understand your point of view. For me it could be great for proposing an app really cross plateform. Desktop, and web without rewriting the server side and db transaction |
@guillaume23 Can you provide a real world use case where you would want to bundle the back-end with the frontend? IMHO it wouldn't be a good idea to bundle the back-end with the app. And even if you still want to do that, then write the back-end in node.js and you'll be able to bundle it as-is in Electron. If you still want to use PHP and bundle it in the app, which is a terrible terrible idea IMHO because rewriting the php parts in node.js is worth it for various reasons, then please use some alternative like Tide SDK. IMO Bundling PHP support in Electron would be bloatware. Sure you can use a third-party node module to bridge between php and node but integrating it into Electron would mean that the 99.9999% people would get bloatware that they would never use. A more sane alternative to this would be to have a PHP app that exposes an API which you can interact with from Node.js. |
I don't personally bundle PHP applications into desktop apps. But as the creator of the PHP-Webkit NW.js boiler plate I can tell you a lot of people do. That project alone has 61 stars on Github as of now. There are actually several PHP desktop app containers out their with pretty decent user bases. If it comes to writing the desktop project from scratch I wouldn't use PHP since I know JavaScript and know Electron well. However a lot of users wanting this are wanting to interact with the machine using PHP for one of several reasons.
So I agree PHP support doesn't need to be added to Electron. But if someone wants to then all the power to them. I am currently rewriting PHP-Webkit from a boilerplate to be an actual NPM module an Electron or NW.js user can simply require and include PHP projects a little bit easier. Unfortunately it is a time permitting kind of thing. |
I have to disagree with you @steelbrain. PHP's entire purpose was to enhance static HTML pages. Electron lets you serve static HTML pages. There is a extra overhead to enabling PHP in Electron due to the JavaScript-oriented nature of the system, but it's not fundamentally wrong. PHP isn't just for servers/backend stuff. It excels at that, but it can be primarily used for both client-focused stuff and backend-focused stuff. Just like JavaScript is now thanks to Node. It makes sense why someone would want to enable processing of PHP files because a ton of websites, web apps and open source projects (Wordpress, MediaWiki, etc.) use PHP. If Electron is being billed as a way to run web apps on the desktop, enabling pre-processing of HTML makes sense even if there is a slight resource overhead for doing the pre-processing for every page load. I think it's not the most efficient method to get the job done using Electron, PHP apps would probably be slightly out-performed by an identical app that's undergone a JS rewrite, but given the pros vs a slight performance hit, it makes sense for this to be a thing. Especially if it's a stepping stone for people to actually do the rewrites in JavaScript. Think of it kind of like training wheels for fully adopting this much more modern app distribution model. |
Can confirm, is bloatware. That said, I've bundled PHP in Electron with Docker containers. It works and gives an interesting mix of capabilities at the expense of performance. That said, I'm leaving PHP alone in the client front end and writing it in JS, just leaving the existing PHP rendered pages for admin/power user section of the app so I don't have to rewrite all that. |
Hi @johnpwarren :) I'm have a PHP webapp that needs to become a desktop app that has to work without internet connection. Unfortunately I can't migrate in NodeJS all the webapp so I am trying to make it work using Electron and 'gulp-connect-php' but I'm more interested in understand your proposal with Docker :D |
Just got it working as a low priority task for work a week ago, so too early to blog about it. Basically just dockerize your PHP app, in my case this was an official Nginx container, an official MariaDB container and a customized official PHP7-FPM container (on a Mac you'll want to sign up for and use the Docker native beta). Tie them together with docker-compose, enter a /etc/hosts entry for the web server locally, then just point the Electron renderer (usually main.js) to the hostname. It's really slow, rendering the same docker group in the browser is easily 5x faster than in Electron (not sure why yet), but seems to be fully functional. Packaging (that I have not gotten to yet) is going to be important as you'll have to have a version of docker and docker-compose verified or installed first and a host file entry working (still easier than keeping a native local LAMP stack installed). Customizing the dockers to run for a single desktop user is also going to be important as by default they each grab 2Gb of memory and way too many default procs for a desktop app, so I was running a very slow install of Drupal 7 in Electron at almost 7Gb of RAM with the mostly default containers. Drupal 8 seems to have an install bug with Nginx, but the plan is to use that with the Waterwheel project and Electron/Node for our app and Drupal/PHP will just be the backend for managing a ton of dynamic content. |
Thanks so much @johnpwarren :)That's a great idea, I'll try to make it work. If you blog about it let me know! |
@theBliz Just wanted to update, trimming down the resources in docker-compose.yml fixed the performance issues for me. I had pushed into my swap with the 7GB beast and everything else I had running at the time. |
FYI, I got PHP Running on Electron using Gulp-Electron-php, will post a template on github soon. |
@sarabveer , Please post the tutorial . We are waiting for you. |
@lakinmohapatra All I did honestly was follow that French Article Above. |
Do you want i post it ?? |
EDIT 2020-05-30:i wrote this when i was 17 and inexperienced with electron and php. but i won't delete it so nothing breaks (but don't read it, don't use it, it's baragouin) hey hey hey!i finally found the easiest solution to do php stuff in electron so basically, i think all php GET request are possible in electron, POST request actually not really first of, you need to have node.js and npm (included in node.js), but i think you probably already have that then, go to command line (as admin) and type:
then:
then go to now include this inside the head tag of your now, the complex part:go to your main javascript file and convert all javascript, jquery or ajax post requests to xhr post requests by hand, just google the syntax of the xhr function for help with that or follow the example below so you should just have post requests like this:
this part is very important! you have to use xhr methods to get it working so, that's the solution...no embedding, not much extra code, no gulp-php-stuff just rebuild your app now and it should work PS: answers like "doing this would make no sense, now learn a new language please" when someone asks for a easy workaround at least, are just bullshit...sorry for saying that, but as developers we all know that we first want to look for an easy way to do things with the resources we have...just ignoring the question and making the asker feel super bad for not wanting to rewrite his whole app, THAT makes no sense...php is just a language and i assume the right to use it like i want, damn peace out |
Wait what, how does that parse the PHP and send Data Back? |
So basically, you can't run PHP inside an Now add this to your
|
@sarabveer
for me even this works:
sending:
|
yea, but how is the php file being executed? @nnmrts |
@guillaume23 Please post the article . |
you can use https://www.npmjs.com/package/gulp-connect-php to run php in electron |
@embluk you can try this havnt used this personally myself |
@crownemmanuel |
@crownemmanuel That is cool! Been wanting to dive deeper into laravel. You by any chance have have app like you show on GitHub anywhere? Thanks! |
You can # use php in electron, get a clone and enjoy php. |
@anggagewor Can you help with the configuration for laravel? |
You can use php in electron, get a clone and enjoy php. |
Does not support mac and linux, so not a good one |
does support mac and linux get mac and linux binaries insert into it as it is and get the app working |
Is there a way I can create a PHP app with this?
The text was updated successfully, but these errors were encountered: