views:

40

answers:

2

I'm looking for inputs into how I can manage the upgrade process itself of a homegrown php/mysql application. Meaning, if we have a 'stable' version of our php/mysql application working on our production server, and we now want to upgrade it to the next version that we've worked on - how do we go about doing that elegantly? What practices should I be implementing?

What I was planning to do was just to

  1. Ask the developers to stop checking in code after all stability / functionality tests are done

  2. Take the application offline*** (Q: how should I prevent ppl for logging in / accessing public pages? Best practices for that?) but allow access to developers through a secret login page / url

  3. Log onto the production server and check out the latest version locally***
  4. Have the developers/testers test their code through the secret access page / url***
  5. After that is done, we restore access to all by removing this secret access page / url, removing the site-under-maintenance page and restoring access to all.

***NOTE: A simple way of doing this would be to rename /myapp/ to /myapp.old/ and put the new application version into /myapp.new/ Developers would access /myapp.new/, test to their satisfaction and then after we're done, we would rename this back to /myapp/ (this is just the basic idea)

+2  A: 

This is a huge question, and in many ways it will depend on your specific project. But here are some practices to think about:

  1. Put lots of comments in your code. Things that seem perfectly logical now will be confusing when you go back to make changes in a year or two.

  2. Maintain a development version of the site with its own database. You can test changes to the site before publishing to your production site.

  3. Use a PHP framework (such as CakePHP, CodeIgniter, etc). If you are far along on your project, this may be difficult to do. But it will help you write code in a way that is easy to update, and will include a lot of stable, mature functions that you won't have to write from scratch. Using one of these frameworks (and following its best practices) is probably the best way for a beginner to learn to think about writing modular code that's easy to update. This will also encourage you to develop your database in a way that is consistent with the structure of your site.

  4. Write tests (the framework should help you with this) to programatically check your code for errors.

  5. Use a version control system such as Subversion or Git. This allows you to track changes to the site, and easily roll back changes if/when you realize they are buggy.

handsofaten
I would add - use an automated build tool like Phing to enable repeatable, hands-off builds (narrowing your chances of making a mistake and allowing a problem to slip through to production). The other nice thing about going this route is that you can integrate your unit testing into your build. A test fails, you don't promote the build to production.
ubermensch
A: 

Comprehensive unit test coverage would be very helpful, as would small, highly cohesive, low-coupled classes. In addition to the unit tests, good coverage from an integration level would be valuable.

Carl Manaster