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()...
Related Soen http://stackoverflow.com/questions/9046675/convert-a-php-script-into-a-stand-alone-windows-executable
– Vinícius
Create executable program with php, html and mysql
– rray
Possible is. Recommendable, maybe not.
– Bacco
off the web you mean localhost, internal network? In this case yes is possible
– SneepS NinjA