Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress Modern WordPress Workflow The Staging Server Staging Hosting

Robert Mews
Robert Mews
11,540 Points

Hosting Noob Question

Hey,

I'm coming from the PHP Track and haven't covered workflow until I saw this course come up. I feel like I'm a cowboy since I've been using a live server for development (shame on me). However, I want to correct this. A few questions.

1) If I use multiple computers (iMac and MacBook) what is the best way to develop locally, or should I just use staging?

2) I've always been accustom to using shared hosting (it's cheap and the GUI makes it easy to install instances of MySQL and MyPHPAdmin. What are the differences between a hosting plan such as this and a VPS? Is it that shared hosting doesn't give you the control that a VPS does since it's shared resources?

3) Finally given this scenario. If you were me, would you pick dump the shared hosting and simply pick a VPS and configure it to run both staging and production environments?

Thanks!

2 Answers

Kevin Korte
Kevin Korte
28,148 Points
  1. I develop on two different computers. One is a Windows 7 desktop, the other is a Macbook Pro. Just depends on location. When I was really new, I used a simple dropbox account to sync up, meaning I copied my entire web project folder from the local computer I finished on, uploaded the whole thing to dropbox and than would go to the second computer, get the files from dropbox, and copy them back into computers local directory. The problem with this is that I had to file history. I was overriding everything that was there from the last save. I than moved on to Git, and pushing to Github, so when I was done at one computer, I push my changes to Github, when I started on the second computer I would pull my changes from Github first, work and push the changes back, and just repeat this process. The nice part about this is that with each push, I had a snapshot of my code, so if I ever needed to, I could go back to it, even if I had deleted it in later steps. Finally, I've just been using an IDE to develop. Currently I use the free tier on Cloud9. I still push with Git, but now I push at milestones, not just randomly when I am done working. The nice part about using an IDE is that my command line stuff also moves with me to each computer, so it's like I never left. It also gives you a very consistent development environment since you are developing on their computer, not yours.The pattern I noticed here is lazyness. Each iteration in my workflow has been towards making it easy. Dropbox was the hardest to manage, Git a little easier (don't forget to push or pull you changes), and finally the IDE (it doesn't matter if you push or pull your changes).

  2. Yes, you are pretty much right. Shared as it sounds is shared resources....you also do not have the configuration control you might have with a VPS. A VPS you get your own instance and your own resources from that computer.

  3. You can certainly do that if you want. You'll have to look at the cost.

Robert Mews
Robert Mews
11,540 Points

Thanks Kevin, that's very helpful. I'm already using Codeanywhere as my preferred IDE. Sounds like I might need to take the course on Git, as I haven't used that yet. I've been so focused on learning to code that you forget how to manage everything and all the different tools.

Robert Mews
Robert Mews
11,540 Points

Kevin, one additional question. If you're using a local machine and using Git for version control, how does that work with SQL databases (seeing as you need to install that on your machine)?

Kevin Korte
Kevin Korte
28,148 Points

Yes so if you're going to develop locally on each computer, and use Git to make sure the computer has the lastest code before you start where you left off on the last computer, than managing the databases does become a bit of a hassle. One think you can do to help yourself is to have the databases on each computer each identical as far as settings go. Same name, same user, same password, so that you should be able to connect to the database without problems regardless of what machine you are using.

The problem is that the data you store in the database won't persist through Git to the other machine. Depends on what your needs are. Many cases, I don't need much data in my test environment so I just create whatever it is I'm storing in the database on each machine. For instance if I was building a blog, I would just create my test posts and comments on each machine and not worry too much about it. But I would only need maybe 6 test posts to get the feel of the app, so it's not much data to replicate.

If you wanted the data to move with you, you could export a copy of your database into a file, and check that file in with Git. Than when you go to the second computer and pull your changes, take the database file and import it into the other database, rinse and repeat.

You could also look at using librarys that help you create dummy data. Here is only one option, but for PHP there is a library called Faker (https://github.com/fzaninotto/Faker). Sure you may still have different data on each machine, but if you're building a social app, it wouldn't matter if you had Mary Sue as a user one machine and Jane Ellen on the other machine. Data is data in that aspect.

Git is a powerful tool, and has a lot. All you really need to know to get started is how it initialize a Git repo, set up your remote Git repo (Github, Bitbucket, etc) git status, git add ., git add -a, git add -A, git commit -m "My commit message", git push, git pull. These are almost all of the git commmands i run 80% of the time. That's all, that's it.

It wouldn't hurt to learn how to use branches as you add features. I typically will use a new branch named after the feature I'm adding, and after I confirm all is good, I'll merge the branch back into the master. If I completely jack up the code when adding the feature, I can delete the branch and my master branch code is as pristine as before I started the modifications for the feature. That's pretty much git checkout -b "Create a new branch if it doesn't exsit" git checkout branch-name this moves you to working in that branch git merge feature merges the feature branch into the branch you're currently on.

I know it sounds confusing, but all of this can be learned quit easily through the courses here. Believe me, I knew nothing about Git, what it was, or how to use it before starting here. It's a tool you won't regret learning how to use.

Robert Mews
Robert Mews
11,540 Points

Thanks so much! So much to cover but this is very helpful.

Rob Turner
Rob Turner
1,458 Points

If you want to keep things local while also being able to work from multiple computers, you could sync your files to a cloud service.

I use a similar solution with Onedrive as part of my Office 365 sub. $70pa for Office, 60 skype minutes (monthly) and 1TB storage (soon to be unlimited). I set certain folders to sync offline and leave the big stuff like my camera roll from my Nexus 5, videos etc in the cloud.

Not sure what the cost is for Apple's equivalent but it would mean you don't need to change your setup that much, work from multiple computers seamlessly and have a backup should they break.