Page 1 of 1

Update system for PHP script.

Posted: Thu Apr 08, 2010 11:16 am
by eFishy
Hi everyone,

I am building a remote control panel which will be licensed out to clients.
There obviously be updates, bug fixes andnew features come over time, and I am looking for a way to have an update button in their admin panel.

This will then automated the process of downloading and installing the required files.
I was just wondering what you think are the best techniques for this kind system.
From a few quick googles I have found very little documentation about this kind of process.

Some potential problems I were thinking of:
can you update php files while they might actually be in use?
should a separated system/service be used?
suppose clients may be missing 1+ updates, in which case they would need applying first..
I expect your list may go even further...

Cheers!

Re: Update system for PHP script.

Posted: Thu Apr 08, 2010 2:06 pm
by alex.barylski
can you update php files while they might actually be in use?
That is a very good possibility, yes. Especially when you have more than a single client using the same software.

I upload the latest copy as a temp directory and then route requests to a temp down page, rename the existing folder to .old and the new folder to the existing name. When users have tested the software thouroughly, I delete the old folder in 5 days.

Cheers,
Alex

Re: Update system for PHP script.

Posted: Thu Apr 08, 2010 3:58 pm
by eFishy
So when I present the user with a "Click Here to Update" button...
I take it the best option would be to have this trigger a shell script which will WGET and untar the update files?

Re: Update system for PHP script.

Posted: Tue Apr 13, 2010 6:09 pm
by Bruno De Barros
If you have root access, sure. Otherwise, use FTP.

By the way, don't forget about database updates (if you need to do any). Lately, I've been through this problem with some of the scripts I've deployed for a few clients, and I think I'm just going to develop something to help remotely deploy scripts, along with their databases, and find ways to keep them updated properly. :P

Re: Update system for PHP script.

Posted: Fri Apr 16, 2010 2:49 pm
by dirkers
You might want to look into setting up a Pear or Pecl channel for distributing and updating your app.

Another option might be PHAR (PHP Archives).

Re: Update system for PHP script.

Posted: Sun Apr 25, 2010 6:53 am
by kaisellgren
Lock the files that you update, update them, and release the lock. Maybe setting some global option "maintenance" to true and show the visitors that there's an ongoing update. Also, it would be a good idea to calculate a hash of the update files on your central server, and then recalculate the hash of the downloaded update to see if it matches.

Re: Update system for PHP script.

Posted: Sun Apr 25, 2010 11:42 am
by Zyxist
Don't forget about the configuration files where you cannot simply replace an old file with a new one. Here you should have a tool that would take both of the versions, compare them and rewrite the old settings to the new file before deploying it.

Re: Update system for PHP script.

Posted: Sat May 01, 2010 4:18 pm
by eFishy
Thanks for the tip's people, going to have a go at trying a few methods to see what I like the best.
Any more ideas would be great :)