How do you manage PHP Project Development Lifecycle? - php

I've worked on several PHP projects and always I have problems with organizing my work. Where do you develop your application - on localhost, remote server or maybe production one(!) ?
When I work on my localhost after making some major path I send new files by ftp - but sometimes it happens to forget about one file and it is just tiring to browse several directiores to copy changed files.
What best practises do you propose?

This is how we manage our commercial site:
Develop in a local sand box
Check-in to SVN
Automated build/test from SVN onto internal
dev server
Scripted deploy using rsync to staging
server for QA/UAT
Scripted deploy onto production
servers.
Staging and production servers are both hosted by the ISP and are hardware and version matched and run RHEL, internal Dev server is version matched CentOS.
This way, when code hits the production servers there shouldn't be any nasty surprises as even the deploy scripts get checked in stage 4.

Google App Engine has an apposite tool that automatically uploads to the production environment files that are modified; don't know if there's something similar for PHP.
So, doing a dev2prod script (a script that does this automatically) should be a good solution.
To do local source file management, everyone may suggest you to use a source code control system.

I'm developing on a development machine which has an identical enviroment like the production one - that prevents some different behaviour because of different versions or configs. after finishing i just move all the files on to the production server.
Winmerge is a nice and free windows tool to diff your files between development and production machine.

Develop in your local machine with the same exact configuration as your development enviroment (that is apache mods, php extensions and so on), using a version control system (I prefer SVN) to keep track of modified files and what not.
Then you can write a script in your production or testing enviroment to copy/update files off the repository to the web server path.

Probably get told off for redirecting an old post but here's how I do it using free tools:
I use Netbeans, Git, bitbucket, source tree, gitflow and FTPloy.
Bitbucket.com : sign up for free account.
SourceTree: free from bitbucket. Great tool for managing git repositories. All commits, merges and pulls can be done in here. Issues in bitbucket can be tracked.
In sourcetree, take the master branch and click "git flow" - google gitflow - it's fantastic work flow of feature, hotfix, development, and release branches and sourcetree helps automate the process.
FTPloy.com automates the deployment of your master branch. Free is one repo/server. But worth the upgrade if you want to push development branch to a server sandbox for testing.
Hope this helps someone searching the web!

This is my own PHP Development lifecycle.
Create a GIT Private Repository on Github or Bitbucket.
Connect the GIT with cPanel. (It's very easy to commit the changes to the repo as well as a production server).
Develop on Localhost(probably on Xampp on Windows) with Visual Studio Code or Sublime Text
Initialise GIT and connected with the private repository.
Push the changes to the GIT repository (master/branches) - master changes will upload to the production server automatically.

Related

Git Server With A Working Copy

I am looking to set up a remote repository on a server that I can push changes on a website to. However, I also want to server to have a working directory, or at least be able have the development version of the website running with the latest changes to the repository.
Do I need to create a local branch on the server to checkout the repository files every time I push changes? Or is there a better way?
I highly recommend you use Capistrano. It is a tool that makes it very easy to deploy a website. It would handle creating a local git repository on your server and checking out the latest version when you run the deploy script. It makes it very easy to deploy to multiple environments (development, staging, production) and it also makes it easy to rollback to previous versions if you discover a bug. All of this is done from your local computer, you would not have to log in to the server after having everything setup.

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.

Deploying website to an external test server with Eclipse

I need an effective way to automatically push changes made in Eclipse to a test web server. These are all PHP changes. I am thinking SCP or FTP would be great with an easy to use plugin, but I would be open to other suggestions.
Background
At my company, we have Windows development machines, but the only way to test the PHP is to push the code over to a Linux machine that is running an Apache installation. Normally, I would just test locally, using WAMPServer or XAMPP, but I just started with the company and their code base is full of OS specific code (one day we will fix that!).
I have currently setup Git on my machine and I simply commit everything over to a bare repo on the test server. Then I have a post-receive hook that forces a pull into the actual Apache web accessible folder.
This git setup works fine, but I really don't like polluting the blame log with useless commits (i.e. I added a comma to line X in javascript). Things like that are not useful to other developers.
In the end, I won't be pushing from my test server anyway. Instead, I'll be pushing from my Windows machine to a central git server for our team (once I get it set up), so I'm not really sure we should be using version control to deploy to the test web server. It seems like using an SCP or FTP plugin would make the most sense.
Question Restated
Are there any Eclipse plugins that could automatically SCP/FTP to a directory on file save? I've searched the Eclipse market place and I am really not sure where to go with this.
Thanks for your help!
Have a look at the Remote System Explorer plugin for Eclipse: http://eclipse.org/tm/

GIT - Web Development workflow/deployment

I'm part of a team of 3 (2 developers and 1 designer) who sometimes work in the office and sometimes remotely and I'm looking at a way of using GIT to develop our websites seamlessly. I've got a managed account with Rackspace and have 3 servers setup on the account - development, staging and production.
I'm looking at the best way for our team to develop daily on our websites without having to FTP the files up to the server each time we make any changes. I've used SVN in the past but i'm looking to use Git for version control. The workflow I had in mind for an example website called 'test' was the following:
Development Server would have a directory (called trunk but not sure if it should be called something else?) for each user as well as a central directory. E.g /var/www/test/jbloggs/, /var/www/test/asmith/, /var/www/test/rjohnson/ and /var/www/test/central/trunk/.
The central repository would be installed within /var/www/test/central/trunk/ and then /asmith/, /rjohnson/ and /jbloggs/ would clone the trunk which would mean they would become /var/www/test/asmith/trunk, /var/www/test/rjohnson/trunk/ and /var/www/test/jbloggs/trunk/.
Each user would then have a copy of /trunk/ which will contain all the website files, will all have a subdomain configured i.e jbloggs.test.development, rjohnson.test.development etc and will configure their IDE to automatically SFTP to the server so that they are working directly within their directory the development server. The central directory domain will be test.development. When they come to committing any changes to the central repository they will SSH into the server and commit their changes and when we want to update the central repository we will pull these changes to get the latest version which can then be viewed at test.development.
Is this the right method of doing things or should we all have a local LAMP stack installed (apart from the designer who uses Windows) and have our repositories locally? If so, should the central repo still be on the rackspace server? The developers will be using phpstorm and the designer dreamweaver.
Hope the above makes sense.
Thanks
I strongly advise you to work local and then commit on the shared server. This is what git is made for. Development will be more reactive and easier for everybody. Make sure all dev master git so they can do their internal soup as they want. If one dev destroy the database, the others can keep on working. But you'll also need a convenient way to synch databases so developers work with an up to date local database.
The rest of your chain is ok, you can still have two test step like dev server for dev team and test server for testers. This will make testers working on a more stable version and it will also make you test the upgrade process when you copy changes from dev server to test server. Lot of errors arise because of untested upgrade procedures.
You can updates changes on test and production server either by installing GIT on them or just using a simple script that will ftp changed files. I don't like having git on a production server but this is a personal opinion.

Version control & synchronization (live & dev) for PHP website?

Recently I have created a PHP/MYSQL based website, site is going to be live in next few weeks, my mentor asked me to setup a dev site and a live site, make changes & testing for new features on dev and then upload them to live.
I can do that but that seems a hard process because I'll make changes here and will upload them manually to live server. There are chances that I'll miss some files or dependencies, while uploading.
I thought to have a SVN kind of facility which will manage the dev and live server synchronization. In case I'll miss any files it will highlight me that this file is not yet synchronized on live etc. Also it will maintain the versions of my live and dev site on daily basis, in case anything goes wrong, we can get the earlier versions.
I am not fully aware with what is SVN, how to setup it and how to use it. Could you guys, please guide me how to setup it and how to use it. Which SVN software will be good.
My Server configs are: its a LAMP facility (Ubuntu)
I am using Windows as a local system to make changes (dreamwaver cs5) and upload them to FTP.
Thanks.
I have a similar configuration to manage dev, staging and deploy for many clients. We still use SVN because it's largerly supported natively and it's also integrated on simple developer tools such as CODA (we're also working with GIT but we plan to move the web app deployment on GIT as soon as it will be integrated in that kind of editors).
On the client side (developers side) you can use any SVN visual client like Versions (OSX).
On the server side, we developed a custom php application to take control of each working copy on the server and run new updates SVNDeploy otherwise you can just ssh on the server and run your custom update.
If you will follow the SVN suggested repositoy structure
/tags
/trunk
/branches
You can easly manage your deployment in this way:
Current release in the /trunk folder
Development snapshots under /branches (like /branches/2.0-dev etc.)
Old released versions under /tags (like /tags/1.0, /tags/1.5 etc.)
We used that configuration in the last 3 years with 5 servers and around 25 developers and it worked fine since now.
Some useful links to configure your own subversion server:
http://svn-ref.assembla.com/subversion-server-guide-mac-os.html
http://aymanh.com/subversion-a-quick-tutorial
Take a look at Mercurial.
There are several videos on YouTube that you can watch to get a feeling for what Mercurial is all about. (Start here.)

Categories