Is it possible to create a desktop application using only PHP, HTML, CSS and jQuery?

Asked

Viewed 10,808 times

19

Although I know that PHP is a language for the web, I would like to know one thing. It is possible in any situation to create an application, system or application with only PHP+HTML+CSS+jQuery that serves an off-web environment (on a Windows or Mac, for example)?

I’ve heard of PHP for Android, but for desktop I’ve heard of such a GTK that I really misunderstood what it was.

  • Related Soen http://stackoverflow.com/questions/9046675/convert-a-php-script-into-a-stand-alone-windows-executable

  • 1
  • 6

    Possible is. Recommendable, maybe not.

  • off the web you mean localhost, internal network? In this case yes is possible

4 answers

14


It is possible to use PHP to make real desktop applications, I I did it because I had to, but it got awful and was soon dropped. PHP decided it would be a niche language, and this is good. Or at least it was when she followed the proper philosophy for this niche. Today I see only one reason to try this: not wanting to learn another language.

Have some attempts to do the browser as a desktop platform, but the results are still well below what can be expected. That is, it would make a web application that would run in a modified browser to look like it’s desktop. Then PHP would work as a server in the same way, but it doesn’t look like a desktop application, it will have many limitations. And you have to rethink the way you program in such a way that it’s better to learn something else and do it right.

  • 2

    "direct" +1

  • I do not agree pq the concept of desktop is far beyond creating exe. PHP is scripting language made for Web. Development is Web and you use GTK to do this. Anyway.

  • @fabricio_wm ?!?!?!?

  • @fabricio_wm vc read the question? And PHP also runs straight on the console, with no HTTP server at all. The "web" part is usually done by apache, Nginx etc, and not by PHP. I agree that the hypertext is a PHP specialty. Web is a consequence only.

  • That’s not the main question, @Bacco.

  • Well, the title was "Is it possible to create a desktop application using only PHP, HTML, CSS and jQuery?" and I think the answer was appropriate. I just made an additional remark, because you commented that "development is web", and it doesn’t make any sense to me just because it’s PHP. However, I am not going to go into too much here, because neither the question nor the answer are mine, and I have accepted this answer.

  • He even uses the term php, html, css and jquery only. I answered exactly what he asked. Desktop has access to machine services. It is possible to make this desktop application not simply pq has an EXE and yes pq I have the features of a desktop application?

  • 3

    @fabricio_wm currently, with Storage site, practically you have everything to run standalone and local, even without PHP. On the other hand, PHP running on-premises and without a web server has access to much more of the OS, and with exec() you do pretty much anything you can’t call natively. Together with GTK, it leaves the browser and has its own UI, with windows, forms and controls, so it really becomes a desktop application. You can even do serial communication with an ECF. Now, that has better language for it, has. But can not say that is not a desktop app.;

  • 1

    @fabricio_wm but as I have already commented on the question itself, I find a nut solution, that is clear this. And in a way that’s what the mustache answered.

  • 1

    Now I wonder what’s wrong with the answer to deserve negative?

  • The question tends to be good, but lack understanding of who has negatived what it means desktop application. Comments shatter the question(some comments.) Maybe @bigown the answer is simple for those who are accustomed to reading their response books.

  • 1

    Well, I believe that the answer was good and objective. That’s why I accepted the answer

  • @durtto may be, but it would be an absurd negative for that. Some people have already denied me because the answer was great :D But that’s what I say, the person does not justify because he knows that there is nothing wrong, I hate to leave something wrong, if there was indeed, I wanted to know what it is.

Show 8 more comments

10

The question is about running PHP as a desktop software but at the same time comments on whether it is possible to run PHP "off the web".

I understand that "outside the web" is also to be able to run PHP within a LAN (local network without internet, in general) and not necessarily as a binary ". exe".

In this case yes, it is possible to create a PHP system to run without using the internet, without having to hire a hosting provider and without having to buy a domain (www... .com). Just install on a PC on the local network and free the ports for browser access. Other Pcs on the same network will be able to access through the browser as if accessing a website, but it is private. Only the local network will have access.

Local Area Network (LAN)

Normally we think of PHP as a website builder and internet language, but obviously we can also build software such as accounting control, customer control, inventory, point card integrated with card reader. You can also use it to create a cashier app for a supermarket, for example, integrated with barcode reader, QR Code and everything. PHP is independent of the internet because a "WEB environment" does not necessarily need to be open to the internet.

What complicates is the visual functions because the interface is in HTML, CSS and Javascript running under a browser. In this case are browser limitations and not PHP itself. For example, you can access Windows Explorer and click and drag files into an HTML explorer. Things like this are complex to do for a web browser and were impossible or super complicated in the past (until 13 years ago), but nowadays it is easier to find solutions especially because in a local network we can have control and impose rules on client-side Pcs. Moreover it is a very specific situation of interaction with file system where not all applications, among the most common, need.

All other functions such as accessing a printer, executing commands and even reboot or shutdown in the Operating System are possible and accessible.

PHP Built-in web server

In PHP 5.4 a built-in PHP compiler server was introduced. http://php.net/manual/en/features.commandline.webserver.php

The use is very simple, dispensing with a third-party web server like Lighthttp, Nginx, Apache, IIS, among others. **It does not mean that it replaces them.*

This means that you can only invoke PHP from a command line, which will launch a built-in web server.

Again, if we think of PHP only as something WEB-oriented, we will be very limited in thinking that PHP is not suitable for other environments. However, it is possible, for example, to run PHP scripts within a Raspberry PI, for example.

With Raspberry we can build from a simple LED switch to a robot with artificial intelligence. And why not be able to control this with PHP or at least some functions that could be written more practical and faster with PHP?

This is possible and already widely used nowadays. Simple to do, simple to maintain. All you need is a text editor and a console (that little black screen) or a browser to test.

There are a thousand and one utilities, for example, build in PHP a network router, an alarm system, telephone call router, VOIP controller, a remote control cart, send commands directly to the telephone network (that’s right, directly to a phone line, without needing the phone), among many things.

A PHP programmer does not necessarily need to be a "website maker". There are "zillions" of applications that can be made in addition to websites.

PHP compiled as a binary . exe

It is possible, as already commented in the other answers. It is an old concept and I believe we can say, "outdated". We currently have better features as mentioned above, and we don’t necessarily need to think that a desktop application should be a "binary. exe" or have that classic desktop software look.

It is common to see PHP applications running with a webserver and a browser, but "disguised" within a window compiled in another desktop language, so that it looks like desktop software. This type of use is horrible and unnecessary. But it goes from the choice of each one. Personally I see no problem in the user to open an application using a browser and that has there all the resources of a browser including see the source HTML, the URL bar, etc. Many claim security issues, but at this point we enter another very extensive subject, which it is not appropriate to comment on here.

However, compiling PHP scripts as a binary is not recommended due to the limitations and difficulties you will encounter. But it is possible. If you’re a Mazoquist, go that way.

Cross-Platform

PHP is cross-Platform. That is, it can run on Linux (including OS-X/Mac) or Windows. Obviously there are specific functions and features for each environment, however, in general, the same PHP code you wrote under Windows environment will work in other environments. This is a great advantage. Easy to build and easy to maintain.

Remarks

There are certain cases where it is best to use a specific language. The choice depends on the application requirements. Just don’t think too much as if you could build a Hádrons speaker with PHP, for example. Or as if PHP were something limited and focused only to make websites with $_GET, $_POST, explode(), strpos()...

6

There was a project called php-gtk, but it was decontined.

GTK is a library or graphical api that provides the graphical objects widely used in linux environment, but which also has versions for windows and mac. Lines were inserted to create windows, buttons, etc, which was used in a php script.

In addition to this is Wxphp which is newer (but which I never used), Winbinder which is only for windows and php-Qt.

What exists (and is most used) are php script to run on a console (command line)

4

From what I could understand by searching, yes, it is possible using a PHP extension called GTK, and yes, it is crossplatform (Windows, Linux, Mac, [insert here the OS]). From what I could read, it is not pure PHP that is used, but a mixed version, PHP + GTK, which probably supports more internal things in the system.

From what I can tell the site itself doesn’t give you much definition of what the thing does in itself, and how but...

follows link: http://gtk.php.net/

Browser other questions tagged

You are not signed in. Login or sign up in order to post.