Home Download Buy Blog Forum Support

Workflow and IDE for web application building

Workflow and IDE for web application building

Postby yumology on Sat Feb 16, 2013 5:14 am

Hello. I am currently working on a website with another person. We both use ST2 as our editor of choice. Our dev website recently moved from a windows machine to a linux one. With windows it was fairly easy because since we were also using a windows machine we mounted our T: drives to be where the htdocs are and by using ST2 we could open files directly on the web server, edit them and save them.

Now that the files have moved to linux things are much more difficult. I am trying to find a solution to the following 3 problems.

1. What's a good way to use Sublime Text 2 to edit the files on the linux server? (Download entire site locally, install WAMP stack on my pc, open up firewall rules to connect my PC to our database server, make changes then FTP changes back to server? Sounds horrid!)
2. What kind of methods are there to protect my teammate and me from writing over each others changes if we are both working on the site at the same time?
3. After solving the above 2 problems, what would be the best method to then push updates from the dev web server to the production one?

It seams like there should be a plugin or program that I'm missing that can handle all of this somehow. I think git can take care of some of it but I'm not seeing any tutorials on using ST2 to automatically pull and push files using git, or finding out what happens if 2 people have the same file opened and editing.
Posts: 3
Joined: Fri Feb 15, 2013 12:53 am

Re: Workflow and IDE for web application building

Postby iamntz on Sat Feb 16, 2013 6:38 am

Let me introduce a very good friend of mine: Git.
You can use bitbucket as private hosting.

As for tutorial: probably you have a slightly flawed workflow. When I first started with version control I was very confused, since I didn't understand how the hell i'm supposed to sync with the server on every single file change. It turned out that I don't have to do that and git bash is a fairly easy tool.

Probably this will help you: http://nvie.com/posts/a-successful-git-branching-model/

Long story short: pull, create a branch, do the work, merge into development branch, push. Reiterate.
Posts: 1035
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Workflow and IDE for web application building

Postby qgates on Sat Feb 16, 2013 6:53 am

You're asking some bigger questions here, beyond the remit of an individual text editor or any tool. You need to set up you're environment around your preferred workflow and within the limitations of the setup you're running. There are plugins that can help with automating workflow once you've set things up, and version control will definitely help if you're working among a team on a central "source tree". If you're using git, you should read up a little on how to use git for that purpose - there are plenty of guides - then look at using the Sublime Git plugin to make the routines of working with git (eg. checking files in and out) easy.

To answer a specific point, you don't mention whether your linux server is local (lan) or remote. If it's on your lan, things should be very easy and you can continue much as you were before. Set up samba shares on your linux server, then map T: on your windows box(s) to one of them, then edit things on the T: drive much as before. If your linux server is remote you can use various approaches - sftp will get you there via ftp, or you can make a vpn tunnel between your networks then work on the remote server as if it's local using samba as above. You could alternatively set up git to directly check stuff in and out of the remote tree, then work with git repositories locally. Git has plenty of tools to manage this and can handle different commits concurrently, allowing for the possibility of manual or automatic merging etc.. You could also use bitbucket or github to host your source trees; bitbucket is sometimes preferred since it allows some free private projects, whereas github charges for this and is free for open source projects.

You might want to read some more about such things with git:
http://pettermahlen.com/2010/03/28/code ... g-use-git/
(or more generally) http://www.infoq.com/articles/agile-version-control
(and of course) http://git-scm.com/documentation

There are many ways to approach these problems; Sublime can help simplify repetitive tasks but won't just "do it all for you" - you need to understand what you're trying to do first, then decide upon an approach, set up your environment then choose and customise the tools to fit your approach. And of course, be prepared to invest some time learning systems like git and ways to improve upon your workflow approaches. It's time well spent in the long run.

Good luck! :)
Posts: 277
Joined: Mon Nov 05, 2012 4:33 pm

Re: Workflow and IDE for web application building

Postby Valtiel on Sat Feb 16, 2013 7:05 pm

Yeah it's not likely you'll find one tool/plugin that is going to do all this for you. You have to figure out your workflow first and set up your tools accordingly.

Regarding question 2, you should just set up a separate test server instance for each developer so you can both be running/testing your own working copy of the code without trampling over eachother and without having to go through Git constantly for every minor change. Git or other source control software (I prefer Mercurial) certainly solves your question 3 and you absolutely should be using version control if you work on a project with someone else (or even when working by yourself, really), but personally I wouldn't want to use it in a way where I have to check in every code change I make just to be able to sync it to my test server.

I also work on a site with one other person and the way we have it set up is we wrote a bash script that monitors the working directory on our local machine for file changes and automatically scps the changed files to the remote test server, where we each have our own code directory and our own test server instance running so we never get in each other's way during development. We experimented with other methods before settling on this one, such as mounting the remote code directories via tunneled nfs/samba shares but we could never get that running with a performance that was acceptable to us (editors would constantly freeze, and operations like Find in Files would take forever). And we weren't happy with any third-party file syncing tools we tried. And the infrastructure of our site is difficult to replicate on a local test server so we have to make due with some sort of remote syncing for now. The method of scping files over to the remote server actually has a pretty minimal delay, especially if you use a control master ssh session. And the script also automatically takes care of some other tasks while it syncs, like re-generating the minified CSS/JS files when a change is made to the CSS/JS code and restarting the test server so it reloads the changed source files. Usually the sync+restart is already done between the time I hit CTRL+S and the time it takes me to go to my Firefox window and hit F5 so most of the time I don't even notice that I'm not running the code locally. We both run Unix-like OSes though, which made developing a tool like that relatively painless. I have no idea how much work would be involved in creating something like that for Windows, since the Windows commandline lacks some of the tools necessary to do this (but a Windows version of scp does exist).

We use Mercurial for version control, and push our changes to the main repository when we're done developing/testing them. And all the web servers pull changes from that repository when we're ready to put them live.

It's a setup that has worked well for us so far.
Posts: 4
Joined: Sun Feb 10, 2013 3:12 pm

Re: Workflow and IDE for web application building

Postby yumology on Sun Feb 17, 2013 7:43 am

Thanks for all the tips guys. Git is now my new little friend too. It's going to be a while for me to get used to it I think. Right now in my head I picture there being 4 master timelines that will be used (not once using branches). 1 on the production server, 1 on the dev server and 1 each on the developers systems. I'm going to completely ignore "hotfix", "support", "release" branches because they don't seem to have a purpose other than "look at this fancy way of doing the same thing you've normally been doing". I don't understand how to branch off the dev server onto my laptop yet. I will pull from the dev master timeline and not branch from it.

I think the whole system is bulky and archaic still. I wish there was 1 production server and 1 dev server. I wish that I didn't have to put our entire website on my laptop and install nginx/apache, php, mysql, git etc on my laptop. Having this process makes it very daunting to assign small tasks for someone to help me on this site.It costs a lot of time effort and training to get set up just to begin working on the site. But I really dont' see a better way. A website simply doesn't work when you move it from Linux to Windows always. It is like I'm moving from 'developer' to 'system admin' when I start installing all this stuff on my own laptop. I'll be scrambling for missing .dll files to get PHP to work with MS SQL or OLE DB and dealing with many more other nuisances.

It would be nice for a dev server to handle all of the multiple users editing it and create branches for each user to do their dev work on it and all the while sublime text is plugged in senselessly. Then when my feature is done I can merge to the dev master branch and let testers know to try it. Branching off dev master would be ideal so that you can check how many users have branches and what changes they've been doing. I don't see how that's possible when someone else pulls from the dev master. I'd have no visibility into what they've done unless they publish their remote branch which I don't understand that concept at all yet.

TLDR; Git is deep shit. It'll take me a long time to get good at it. However it looks like the best solution. Thanks!
Posts: 3
Joined: Fri Feb 15, 2013 12:53 am

Re: Workflow and IDE for web application building

Postby iamntz on Sun Feb 17, 2013 8:17 am

You could also look into vagrant to set up a virtual machine to run an environment similar to production server.
Even if the initial setup might be complicated, after you have the VM done, all you have to do on a new machine is:
Code: Select all
vagrant up

It's recommended to have a local dev environment. It's faster (no network can beat saving locally, no matter how fast it is!) and more reliable. Think what's happen if your connection drops for a week or two.

Now, about Git:
I have the feeling that you didn't understand branching model. It's not a branch per user, it's a branch per feature. My branching model looks like this:

• master branch. That is the secondary branch, that is in production.
• develop branch. That is main branch, where i do the work and is pushed to test server. On release day i merge it into master and push to live server. Each release also have a tag for version (like v1.2)
• countless other branches that are made for new features/bug fixes. If the change is small (one, two commits), I made it dirrectly on the develop branch. It's a normal thing to work on something big..ish and my client come and tell me „do this very quick change here”. I switch branch, do the stuff, push, then change back. Everybody is happy :)

Probably it's a good idea to squash commits when you merge into parent branch. If, let's say, new feature branch has 20 commits, probably you won't want to see those commits into develop branch (or when you merge develop into master).

And no, you don't need to be 100% in sync every single second with your server/co-workers (and this was one of the most dificult thing to grasp when i first started to use version control)

== edit ==
I wish that I didn't have to put our entire website on my laptop and install nginx/apache, php, mysql, git etc on my laptop.

If you are a PHP developer is less likely to not have these installed already :)
Posts: 1035
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: Workflow and IDE for web application building

Postby qgates on Tue Feb 19, 2013 2:07 am

Re. VCSs, You might want to check out Mercurial as well. I've used both along the way; though Git is my preferred VCS, Mercurial is well-regarded (ie. pro) and has a few benefits:

1. It's easier for newbies - commands are similar but generally simpler and less confusing. I heard a colleague say some years ago that Mercurial is like git but doesn't require a degree to use it.
2. It natively plays nice with Windows, as well as Linux and Mac. Git works on windows using a cygwin style bash layer/emulation.
3. Mercurial is optimised to handle BLOBs natively. Git has an extension for that purpose (git-annex) but it doesn't play on Windows.
4. There are nicer native Windows GUIs, apparently. Though git-gui is OK and does what you need, it looks very 90s. Beyond that I dunno, I tend to work on command lines.
5. It definitely performs better in Windows when working with large/complex projects, due to its native support.

Bitbucket, mentioned above, is a service provided by the same people who make/promote Mercurial, so it supports both Mercurial and Git.

I'm sure it would be very trivial to fix the Git plugin for Sublime to make it work with Mercurial as well. Maybe someone already did that.

Posts: 277
Joined: Mon Nov 05, 2012 4:33 pm

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 32 guests