Question

I've noticed while developing my first site, that the smallest changes in database columns, connection options, and various other components cause the website to fail until I correct the problem which may or may not require a lot of time (woe is me). I'm wondering what steps I can take now in order to prevent these headaches, as I've delayed the website launch in order to keep upgrading. Once I'm done implementing the changes I would like to see, I know I won't truly be done, but at some point I have to move on to the next stage.

Yes, I know there is probably no one good solution, and ultimately a self-correcting design is more trouble than its worth at this point. But if any grey beards have any tips that they could offer based on their own experiences working with WebDev, particularly with LAMP stacks, I would greatly appreciate it.

Specifically, I would like to know what to look out for when modifying databases and website code after customer information is in active use, in order to prevent errors, and how to roll out the changes.

EDIT 1:

Yes, so the answer seems to be that I need to copy the live site to my testing environment. I'm looking going to some of the already suggested development solutions. Regular backups are crucial, but I can just see inserting new columns and modifying queries as a cause for mis-ordered tables and such. "That's where being a good programmer and testing diligently comes in handy", someone in the corner said. As I look into the proposed solutions, I welcome all others in the meantime. A real-time copy of the 'live-site' would be nice to create on the fly during testing.

Was it helpful?

Solution

The above answers are all very valid and in the end, they represent your target solution.

In the meantime, you may already do a lot for your website, even with a gradual migration to those practices.

In order to do so, I suggest you to install PHPUnit (or whatever Unit comes with the web languages you use). There are also "graphical" versions of it, like VisualPHPUnit, if that's more of your taste.

These tools are not the permanent solution. You should actually aim adding them to your permanent solution, that is setting up development server etc. However, even as interim solution they help you reach a fairly stable degree of quality for your software components and avoid 80-90% of the surprises that come with coding on a live server.

You can develop your code in a separate directory and test it before you move it into production. You can create mock objects which your code under test may freely interact with, without fear of repercussions. Your tests may load their own alternate configuration so they work on a second, copy database. Moving even further, you may include your website into tests itself. There are several applications like Selenium that allow you both to automate and test your production website, so that you can reliably know that your latest changes did not negatively affect your website semantics.

In short, while you should certainly aim at getting a proper development environment running, you can do something very good even today, with few hours of study.

OTHER TIPS

Start using some (maybe simplified) sort of release management:

  1. Maintain a development environment. Either locally, or in a second .htaccess-protected folder online. Make it use it´s own db.
  2. Test every change in this dev env. Once you are satisfied, move them to productive env.
  3. Use git or svn (svn might be simpler to learn, but opinions vary. Checkout "tortoise") to save a snapshot ("commit") of every change you make. That way you can diff throu your latest commits if anything goes wrong.
  4. Maintain regular backups.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top