r/PHPhelp • • Nov 26 '16

Possible to convert your PHP website to software?

So it can be used offline on a computer. People install it and they have the exact website with the PHP functionalities on their computer.

Is this possible and if so, how?

Thanks, Rookie (Drag&Drop developer)

8 Upvotes

13 comments sorted by

2

u/[deleted] Nov 26 '16

Install php and a webserver like apache or nginx on your dev machine... Then you can run your php code by visiting http://localhost

1

u/DrPapillon Nov 26 '16

This seems do-able. Thanks I'll google more about it

2

u/[deleted] Dec 06 '16

Turn your web application into a REST Api that just outputs json. Create your front end in html, css + js and just communicate with the api via ajax. You can then export this using tools like phonegap to native windows/osx and android apps.

You have to be online in order for it to work (although you can get around that with local storage/nosql/web workers) but this keeps your php code secure as well as having a lightweight frontend that can be used either as a webpage or as an app.

1

u/DrPapillon Dec 06 '16

Very useful info, thanks mate

5

u/RandyHoward Nov 26 '16

In theory, yes. Developers do this all the time... we run a local web server to develop a site without actually deploying it to a live server. It runs in the browser though, just like any other website. So in that sense it is not like software that you run on your system, it still behaves like a website. But, in theory, anybody could run a local web server and use your PHP based website offline. Sort of. Any databases you rely on will also need to be made available offline, so you'd have to copy your databases to their machine as well. You'd also need to write some scripts to sync the databases up when a connection can be made. You might be able to bundle all of this up into an installable package, but it's most likely not worth going to that much trouble.

1

u/rasmusdybro Nov 26 '16

I realise that this may be a bit far fetched, but technically - doesn't a lot of frameworks include some kind of webviewer? This would make it seem more like a real application.

2

u/RandyHoward Nov 26 '16

Sure you could certainly do that too to make it seem more like an application, but a website running inside an app container isn't much of a real application beyond aesthetics.

2

u/[deleted] Nov 30 '16

PHP 5.6 has its own built-in webserver too, so at a pinch you can run

php -f index.php -S 127.0.0.1:9090

1

u/Jonne Nov 27 '16

I did this once (despite knowing better than to even attempt this), it's a pain in the ass, especially if the site wasn't built to account for this initially.

1

u/jallits Nov 26 '16

Yes, a great deal of my day is maintenance and enhancements to a middleware application built in PHP. While there are a few views built to show internal users statuses, most of the application operated behind the scenes using event listeners and scheduled tasks.

1

u/evohans Nov 27 '16

I've actually diddled with this for a while, it's decent enough and pretty lightweight. https://github.com/cztomczak/phpdesktop

1

u/liquid_at Nov 27 '16

Since it's a server-side language, you need some form of server.

There are tons of options for offline-machines. Xampp and it's variants (wamp, lamp, mamp, depending on OS you use) work for most basic features.

But when it comes to making it like a software, I'd definitely add javascript and the jQuery library to your feature-list. Php alone will only create static content. if you want the look and feel of software, you'll need client-side processing. javascript works well together with php. somewhat at least xD