views:

85

answers:

5

I know that I can save all my projects files into repository so deployment of new version of software become only using svn export into properly directory. But I have a feeling that it is not right way and for media files I should use some other utilities for deployment like rsync. But it is also a problem with double-side sync = I like to keep backup of full projects into some security space (not only live server). So main question is what is the right way and project's directory structure for web-application in PHP?

A: 

It's absolutely right to put media files into source control (whether svn or something else). It's probably a good idea to put media files somewhere separate from your .php files though.

Why have a two step deployment (svn up and then rsync or similar) when you can do it in one step?

Dominic Rodger
i think you are right.i used to do rsync without excluding .svn direcotries, so i had to do svn export to local folder before rsync (for getting clean code at hosting -- without .svn folders)now i wrote proper excluding templates for rsync so no one .svn files not synchonized.thanks.
mihan007
A: 

It's not wrong to have your media files into your SVN repository, as your medias' version is linked to the rest of your software's.

Besides, if you want to have backups of your svn repository, you can use the svnsync command to have some other box mirror you "main" subversion repository.

About structure, the best practice mainly depends on the use case you are facing. You most likely want to organize your files by modules and content-type (so having media separated from code, ...).

Romain
+1  A: 

Ehh, a complex one.

First of all, if you have such possibility, it's good to split 'code' and 'web' part. Something like that.

web/
web/css/
web/upload
code/
code/lib/
code/actions

This gets PHP out of web root. It's safer (attacer will not be able to access your files by entering URL in browser). BUT - this requires appropriate application design (for example Symfony framework gives you similar layout).

Second thing - there's nothing wrong (in my opinion) with binary files inside SVN repo. It all depends, though, what files we are talking about. If not user-uploaded content - go ahead. The less complex is deployment, the less chance something goes wrong.

BTW: You can always opt-out some folders contents from svn so user files won't mess up with your files.

So one thing you have to keep in your design is to separate user entered content of your content (the best is to create special folders for users and opt them out SVN).

Tomasz Struczyński
A: 

It's fine to put the media files in svn too. You could use for example external svn links to blend the media files into your tree, so you have only one checkout to do and you have full subversion support and you do not clutter your sourcecode repository.

Patrick Cornelissen
A: 

In my opinion, it depends on what type of media you are talking about. If this is something static, like images, javascript, css, and so forth - something that isn't temporary, then put it in subversion. However, if it is something that will change, such as an ad, I don't think there is much reason to subversion it. Just set the directory propset to ignore and upload the files manually with rsync, scp or ftp.

Hans