Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to self-update PHP+MySQL CMS?

Tags:

I'm writing a CMS on PHP+MySQL. I want it to be self-updatable (throw one click in admin panel). What are the best practices?
How to compare current version of cms and a version of the update (application itself and database). Should it just download zip archive, upzip it and overwrite files? (but what to do with files that are no longer used). How to check if an update is downloaded correctly? Also it supports modules and I want this modules to be downloadable from the admin panel of cms.
And how should I update MySQL tables?

like image 598
foreline Avatar asked Mar 13 '10 17:03

foreline


People also ask

What is PHP update statement?

The UPDATE statement is used to update existing records in a table: UPDATE table_name. SET column1=value, column2=value2,...


1 Answers

  • Keep your code in a separate location from configuration and otherwise variable files (uploaded images, cache files, etc.)
  • Keep the modules separate from the main code as well.
  • Make sure your code has file system permissions to change itself (use SuPHP for example).

If you do these, simplest would be to completely download the new version (no incremental patches), and unzip it to a directory adjacent to the one containing the current version. Because there won't be variable files inside the code directory, you can just remove or rename the old one and rename the new one to replace it.

You can keep the version number in a global constant in the code.

As for MySQL, there's no other way than making an upgrade script for every version that changes the DB layout. Even automatic solutions to change the table definition can't know how to update the existing data.

like image 180
Bart van Heukelom Avatar answered Sep 22 '22 12:09

Bart van Heukelom