provide updates to a webapp via a bitbucket repo - php

I have created a simple web-application using PHP, JS etc.. My next step is to deploy it to eg. liveserver.com. I am sure that I will be providing a lot of additional features in the future and so I would like to know how this is generally done. I am pretty sure its a noob question so I tried to google it but nothing helpful came up.
Here is a rough idea on how I may do it. I would keep a local copy in WAMP and keep developing it and sync / push it to bitbucket. The question is : How do I connect the updated bitbucket version to my liveserver.com. I am keen to know how web-developers generally provide updates to their app users. Is there a general update mechanism they follow ? Is my idea of using a version control application wrong for this purpose ? How would you do it for a simple app like this ?
A concise answer would suffice. It would be great if anyone could provide me helpful links or point me to right direction, further information etc. TIA.

You're really asking two questions here:
How do I connect the updated bitbucket version to my liveserver.com?
I would like to know how this (syncing code between test environment and production environment) is generally done, best practices and stuff.
The first question is answered here. The latter, broader question is touched on here but I'd like to offer my personal thoughts as well.
You've mentioned you're using WAMP, whereas I'm coming from a LAMP environment. Regardless, I'm hoping you will find some additional usefulness in my answer as it may help lead you to a Windows-based equivalent solution.
At home/work:
I also use bitbucket and prefer it to github. I have Git installed for source control which allows me to push or pull any code between bitbucket and my local machine.
On the go:
I have AWD IDE installed on my tablet which allows me FTP access to a production environment, and the non-free version also has Git integration. Another great IDE is Cloud 9; completely web-based and convenient if I don't have my tablet with me and need to use a public computer or laptop. Cloud 9 also supports Git.
Syncing:
Rather than push code from Bitbucket to my production server, I prefer to keep a mirror of my production server locally. I use a tool called rsync for this. I have a bash file setup on a cron job that looks something like this:
#!/bin/sh
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
RUSER=remoteUser
RHOST=remoteHost
RPATH=/remote/path/
LPATH=/local/path/mirror/
$RSYNC -av --no-p --delete -O -e $SSH $RUSER#$RHOST:$RPATH $LPATH
So basically, my primary workstation (which is where I do most of my work) is always in sync with the live server. Both the live server and Bitbucket can be updated away from home. Thanks to Git, I can see exactly what has been modified. It's also comforting to know my code exists in three different places for redundancy.
This is what I have found to be most convenient for me, but I would love to know how others do it.

Related

Coding at multiple locations?

At the moment I am using poor method to work at home and at work to do web development.
I use Wamp for testing/development and then I upload to a production web server (Linux) via FTP.
If I continue with the project at home, I have to download the files from FTP.
What is good method to work on same projects at multiple locations?
Someone suggest me to learn Git and get Github private account. Also suggested to get Vagrant installed at work and home. Do I need to install Git in Vagrant VM or local machine?
Learn git: http://try.github.io
Create a Vagrant/VrtualBox VM by following the directions at https://puphpet.com
One of the tricks here is to put the Vagrant stuff you get from Puphpet directly in your project and then commit all of it to git. You'll then be able to check out the project in a new environment and, as long as Vagrant and VirtualBox are installed, you can run vagrant up and be working in about 5 mins.
Here's an example of how I'm doing just that to allow people to easily try out a library I've written: https://github.com/jeremykendall/query-auth-impl.
Enjoy! Your life as a developer is about to get a lot easier and a whole lot better.
Github or Bitbucket. Git or Mercurial, and also Svn if it's just for yourself and you want an easier learning curve.
Any source control system would be ideal for this.
You don't want your production server to be the source of truth for the actual code. Those two concerns should definitely be separated. The production application is the output of the code, not the code itself. For a language like PHP the two may be identical, but the concerns themselves should still be separated. Indeed, for small systems the two services may even be hosted on the same server, but should still be logically separated.
The source control system maintains the changes made to the code over time, the production server is a snapshot of the current release version of the code.

How should i sort out versioning and offline testing on a website

I am an avid webdev hobbyist and freelance, up until now I simply edit the website live (put a maintenance message up while its being made), now all my projects up until now have also been very small.
eg I make a site, show em, take money and go, I've never had to work on a site after it's gone live.
Now my new project is pretty big and I know I will have to edit it after its gone live and maybe have a small team of devs (atm just me)
So how do people professionally handle this? I know I will need a prefix-amp app cos i run an apache server, I've also heared that people use github for versioning, but I'm not really sure because apparently its not svn?
Thanks
ps. I have a windows 7 pc, so no mac apps please
up until now i simply edit the website live
Terrible in my book ;)
so how do people professionally handle this?
First you need to setup a development server (it would be best to keep it as close as possible to the expected live environments). On this server you would install all the software you need.
You may also want to setup a staging server.
i know i will need a prefix-amp app
I hope you are not talking about those one click installers. If you would do it professionally you should install everything yourself that way you can set it up the way you need it.
ive also heared that people use github for versioning, but im not really sure because apparently its not svn?
GitHub is just a website. What you are looking for is git or svn for versioning. You could also setup a git or svn server locally instead of using services like GitHub. Basically what versioning is is that when somebody makes a change to the code he/she would need commit the changes. This way it is easy to keep track of changes in the codebase (like what was changed, when was it changed and by whom).
Local XAMP-stack (LAMP, or WAMP) for development
intranet-system for test and maybe staging
Of course the live system
Versioncontrol, I prefer git. Of course you can use SVN too, but... lets say: It's SVN.
Make changes local, test this changes local
everythings fine: Push it into the "master" vcs-repository
New version ready (or it's "sunday-night-release-time")? Push all that stuff on test/stage
Everythings fine there too: Push it into the live system
Thats very shortened of course, but it should give you an idea.
The tool where you manage your software version is not that important. Use Git, or SVN or whatever, the one you like most. But use _one_.
Equally important is that you run the "page" on two sites, a test and a live system, strictly apart. Both systems have to be very close in their layout, all changes must first be done in the test system, be verified and then done in the same manner in the live system. Do not allow changes only to be made to the live system ('cause it's just a small change'). No exceptions.
Then think about deployment: how will you transfer changed files to the target system ? You need routines for this, that run once started and don't forget a step in between.
Firstly you need some kind of versioning system: either SVN or Git. GitHub is simply an online service that provides managed Git repositories. Secondly you need a development server.
If it were just you doing development, you could host both of these on your local desktop PC, but since other developers are going to be joining, you need a remote server. If you don't want to be running a server out of your home, the best option is a VPS (virtual private server) on which you can install Git, Apache, etc. and anything else you need.
As for development software, take your pick- there are loads of options. A common choice is the NetBeans IDE and TortoiseGit combo. You use NetBeans to develop your code on, automatically uploading to your development server, then you TortoiseGit to commit and sync changes.
Only when you're ready to go live do you copy the code from the dev server to the production server.

Question of Development Methodology

This is the 3rd web project I have been developing and I have been a sole developer in all projects.
Now I need to change my style and don't know how to do it, so I need your suggestions.
My setup is;
Netbeans for PHP development
Github for private repository (As I am developing on Windows I found very hard to integrate Git-Windows-Netbeans so I can change it if needed)
Basecamp for project management (Even if I use GIT, I might change my GIT provider (github) and select a one which can be integrated with Basecamp)
My needs are;
For my current project, I will setup a dev server and test the changes there first. Then I will commit them to the production server. So I should be able to use netbeans while I can easily commit to my repository and apply the changes to the production server. How can I do it easily? Should I first commit to the repository and get the changes from the dev. server via command line? It seems a bit work to do this for every change. Should I directly upload to the dev. server, then commit the final changes to the repository and get the changes from there to the production server?
So, what do you suggest as a repository which can be integrated into the netbeans and how should I manage these changes?
I also would like to use one of these providers (http://basecamphq.com/extras - SOFTWARE DEVELOPMENT TOOLS). So, if you have any suggestions from these companies too, that would be great
Thanks a lot,
Everyone's tastes vary.
There are many IDE/Editors, different version control systems, and even different methods of deploying to a live server.
So really the best way is to just experiment with different methods until you find one that suits you.
I will tell you how i do it, and take from it what you want.
And im sure this will be downvoted by certain people, but its what i found to suit me best.
My editor of choice is vim, but i also like Eclipse with the PDT plugin. Eclipse isn't as "snappy" as netbeans (at least on my computer), but its very nice.
I use SVN for my version control, this is just something that i have been using for years and i am comfortable with.
To deploy the latest code to my live servers i check out the trunk of my svn repo on my live server, for small changes i just commit them directly to trunk, but for larger changes i branch off the code to change, and then merge it back into trunk when its ready.
Then all i need to do is issue a "svn update" on live, and the new code gets checked out of the svn.
To avoid ssh'ing into the machine, this can even be called from a php script, from a protected file somewhere.
<?
$svnuser = username;
$svnpass = pass;
$returnString = exec("svn --username={$svnuser} --password={$svnpass} update 2>&1",$output,$returnVal);
header("Content-Type: text/plain");
print("Return value: {$returnVal}".PHP_EOL);
print("Return String: {$returnString}".PHP_EOL);
foreach($output as $line){
print($line.PHP_EOL);
}
?>

Setup SVN/LAMP/Test Server/ on linux, where to start?

I have a ubuntu machine I have setup. I installed apache2 and php5 on it. I can access the web server from other machines on the network via http://linux-server. I have subversion installed on it. I also have vsftpd installed on it so I can ftp to it from another computer on the network.
Myself and other users currently use dreamweaver to checkin-checkout files directly from our live site to make changes.
I want the connect to the linux server from pc. make the changes on the test server until ready and then pushed to the live site. I want to use subversion also into this workflow as well. but not sure what the best workflow is or how to set this up.
I have no experience with linux, svn, or even using a test server, the checkin/out we are currently doing is the way I have always done it.
I have hit many snags already just getting what I have setup because of my lack of knowledge in the area. Dreamweaver 5 has integration with subversion but I can't figure out how to get it to work.
I want to setup and create the best workflow possible.
I dont expect anyone to be able to give me an answer that will enlighten me enough to know everthing I need to know to do what I want to do (altough if possible that would be great) instead I am looking for maybe a knowledge path like answer. Like a general outline of what I need to do accompanied with links to learn how to do it. like read this book to learn linux, then read this article to learn svn, etc., then you should know what to do. I would be happy just getting it all setup, but I would like to know what I am actually doing while setting it up too.
I'm sure you've solved your issue by now, but for future reference to other users, here's the steps I would suggest to get started:
Create a repository for your project (in Ubuntu)
Host the SVN repo using Apache
I'd read up on the subversion book to look at some strategies for development with SVN.
To connect to your SVN machine, you'll need to use it's IP or hostname instead of your svn live site you mentioned. With proper forwarding, it's easy to access it from anywhere.

PHP Deployment to Live Server

I am new to this, I just reading about how I should not edit code on the live production server. I don't know anything about source control or SVN.
I would like to start coding on a test server then once everything is confirmed working, I want to send all the files over to the production server.
How should I go about this? I am on mac os x and was looking into apps like http://versionsapp.com/ but I am not sure if this is the right solution.
What do you suggest?
If you are new to web development, I wouldn't suggest jumping into Subversion right away. You should have a firm grasp on Subversion before actually using it in any production environment, as its surprisingly easy to screw things up. Don't let that scare you off, though, as version management (whether through SVN or another avenue) is highly useful.
And if the project in question is small enough, I don't see anything wrong with the old "develop locally then ftp it to the server" approach. Sometimes a full-blown version management tool just isn't necessary.
Whether or not a SVN deployment strategy is appropriate depends on factors such as the size of the site, your familiarity with using the command line, and whether you are working as part of a team.
It is worth noting that in most shared hosting environments you won't have the option to install SVN on the server, which narrows your options somewhat!
I don't think there is anything inherently bad about using good old fashioned FTP to get files up to a server, especially for smaller sites where you are the only person working on the site.
Even then, SVN can still be very useful. I keep all my sites under version control even if they are going to be deployed by FTP.
Just go with SVN as it is the basics. After you get a taste of it you can explore the alternatives like GIT or whatever.
You should learn to do the basic SVN stuff through the console, there is no other way especially if you are going to work on a live server. Your live server should have SVN installed and some SSH access so you can execute your SVN command there.
You can also get TortoiseSVN which is a nice visual client for SVN.
The basic SVN you are going to use is those 3 commands:
$ svn co # Checkout
$ svn ci # Commit
$ svn up # Update
There are tons of tutorials of how to do stuff, here is the first one from google:
http://paulstamatiou.com/how-to-subversion-basics
After you feel comfortable with that stuff and when you start working with team and contribute to public repositories you might start exploring the advanced stuff like branches, tags and all other terms that make some people feel important when they mention them.
This versionwhatever.com I would hold for now and explore the popular choices, before specializing, especially that SVN works on UNIX and you can put it on Linux which runs most of the web hosting out there.
Cheers!
If you're just starting out I recommend you avoid SVN. Try git, there are numerous mac tools, such as GitX for Mac. There's also github and others to host your projects for easy pulling and revisions within a group of people.

Categories