nayen — 2013-03-14T04:09:38-04:00 — #1
I am building a self hosted PHP application and I want to have a remote update system that will work like WordPress. So, when the user logs in, if there is an available update, he will see the update button and once clicked, the application will be updated. I searched Google but couldn't find anything to start with. If you have any ideas or resources about this, can you please share here?
markbrown4 — 2013-03-14T04:22:37-04:00 — #2
If it's just the one copy of your application you should be pushing the code to the server with source control like git.
If your software is hosted on many servers it's still possible to just push changes to the different servers.
It's only if it's really distributed and you don't know where your software will be running that I'd consider implementing what you're describing. Even then, you could leave it up to the users of the software to update it.
With all that said it's basically just downloading and replacing the application files, running any database migrations that are required, maybe cleaning up the temporary files and if you're really good having it roll back on failure.
nayen — 2013-03-14T05:08:01-04:00 — #3
Yes, it is distributed and the user will have the option to update or not just as in WordPress. There is no database, just plain .php files. "just downloading and replacing the application files", this is where I have no idea how to handle.
markbrown4 — 2013-03-16T04:55:32-04:00 — #4
Well, you can have a look how Wordpress do it but it's complex.
ravmeister — 2013-03-16T16:13:39-04:00 — #5
The basic flow is like this...
1) Upon log in, connect to remote server and provide current version to see if there are any updates
2) If there are, download zip file in a temp folder, unzip to current app's directory directly overwriting current version
3) New files contain latest version number, so next time they log in, it will do check again, and since there won't be any changes, it does nothing
PHP has a function called ZipArchive which you can use to unzip files, but it's an add-on library and may not be included in all PHP builds by default. So if you are going to execute this through WP, then you can include WP context in your script, and then you'll be able to use all of WP's functions for unzipping files and stuff, and that will save you a lot of coding because WordPress contains all of the plumbing code.
Hope this makes sense.
nayen — 2013-03-18T05:06:58-04:00 — #6
Thanks for your contribution. Your reply is kinda what I was looking for. The flow you described gave me a better understanding on what I should do. Actually, I am already done with the 1st step.
My application is not related to WP, it is a simple self-hosted application with no database. My remote update process will be a lot simpler compared to WP.