Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should I set up my development environment for rolling code into a live website?

Tags:

php

cakephp

In the past, I've always edited all my sites live; wasn't too concerned about my 2 visitors seeing an error message.

However, there may come a day when I get more than 2 visitors. What would be the best approach to testing my changes and then making all the changes go live simultaneously?

Should I copy and paste ever single file into a sub-folder and edit these, then copy them back when I'm done? What if I have full URLs in my code (they'll break if I move them)? Maybe I can use some .htaccess hackery to get around this? What about database dummy test data? Should I dupe all my MySQL tables and reference those instead?

I'm using CakePHP for the particular project I'm concerned about, but I'm curious to know what approaches people are taking both with Cake (which may have tools to assist with this?), and without a framework.


I've been getting a lot of recommendations for SVN, which sounds great, but unfortunately my host doesn't support it :\

like image 992
mpen Avatar asked Apr 06 '09 00:04

mpen


People also ask

How do I get Started with VS Code for web developers?

In this article, I am going to walk you through how to get started and set up VS Code for Web Developers. If you don't yet have VS Code installed on your computer, head to code.visualstudio.com to download it. You can open the dropdown to choose the versions you want to download, but usually, the big button should do the work.

What do I need to set up an integrated development environment?

To actually do work as a developer, you'll need four main things to set up your integrated development environment: a code editor, command line interface (CLI), version control system, and package manager.

Should you edit your code remotely?

There are many advantages to editing code remotely. For one, you don’t have to worry about setting up and maintaining the development environment on your local machine. Other benefits include being able to work from anywhere and collaborate with other developers more easily.

Which editor should I use to build my Web part?

You can use any code editor or IDE that supports client-side development to build your web part, such as: Visual Studio Code Atom Webstorm The steps and examples in this documentation use Visual Studio Code, but you can use any editor of your choice. Install development toolchain prerequisites


2 Answers

The best thing you can do is to create a staging environment in which you test your changes. The staging environment (ideally) is a complete, working duplicate of your production system. This will prevent you from experiencing many headaches and inadvertent production crashes.

If you are working on a small project the best thing to do is to recreate your remote site locally (including the database). Code all your changes there and then, once you are satisfied that you are finished, deploy the changes to your remote site in one go.

like image 145
Andrew Hare Avatar answered Sep 24 '22 13:09

Andrew Hare


I would recommend putting your website code under full version control (git or subversion). Test and maintain your source in a separate, private sandbox server, and just check out the latest stable version at the production site whenever it's ready for release.

For database support, even for small projects I maintain separate development and production databases. You can version the SQL used to generate and maintain your schema and testing or bootstrapping data along with the rest of your site. Manage the database environment used by your site from an easily separated configuration file, and tell your version control solution to ignore it.

Absolute URLs are going to be a problem. If you can't avoid them, you could always store the hostname in the same configuration file and read it as needed... except within stylesheets and Javascript resources, of course. My second choice for that problem would be URL-rewriting magic or its equivalent in the development server, and my last choice would be just messing with the /etc/hosts file when I wanted to test features that depend on them.

like image 26
Ash Wilson Avatar answered Sep 20 '22 13:09

Ash Wilson