SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to remote update self hosted application?

    Hi,

    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?

    Thanks.

  2. #2
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,095
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    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.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by markbrown4 View Post
    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.
    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.

  4. #4
    padawan silver trophybronze trophy markbrown4's Avatar
    Join Date
    Jul 2006
    Location
    Victoria, Australia
    Posts
    4,095
    Mentioned
    28 Post(s)
    Tagged
    1 Thread(s)
    Well, you can have a look how Wordpress do it but it's complex.
    https://github.com/WordPress/WordPre...es/upgrade.php

  5. #5
    SitePoint Member
    Join Date
    Feb 2004
    Location
    San Diego, CA
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.
    Ravi Jayagopal
    Co-Founder & Co-Developer
    http://DigitalAccessPass.com (DAP)
    Membership Plugin For WordPress

  6. #6
    SitePoint Addict
    Join Date
    Nov 2009
    Posts
    284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RavMeister View Post
    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.
    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.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •