views:

59

answers:

2

I have a need to create a library of Object Oriented PHP code that will see much reuse and aspires to be highly flexible and modular. Because of its independent nature I would like it to exist as its own SVN project.

I would like to be able to create a new web project, save it in SVN as its own separate project, and include within it the library project code as well. During this process, while coding the web application code and making commits, I may need to add a class to the library. I would like to be able to do so and commit those changes back to the libraries project code.

In light of all this I could manage the code in two ways

  1. Commit the changes to the library back to a branch of its original base project code and make the branch name relevant to the web project I was using it with

  2. Commit the changes to the library back to the original code, growing it in size regardless of any specific references that might exist.


I have two questions

  • How can I include this library project code into a new project yet not break the subversion functionality, i.e. allowing me to make changes to each project individually?

  • How I can keep the code synchronized? If I choose the first method of managing the library code I may want to grab changes from another branch and pull it in for use in another.

EDIT - I realize I can simply check out these projects individually and commit/update them individually as well, but then how can I include them together as a single project? To be more clear, how could I create a web project that includes the library code as a unified subversion project in consideration of the points I elaborated on above?

+1  A: 

Option #1 looks like the right way to go.

I think you should expect to keep separate branches of the API project for any of your sites that have site-specific modifications to the shared API. Of course, you don't need to create the branch upfront, just checkout the 'trunk' and make sure you branch before you commit any site-specific changes.

There are a couple of articles on branching/merging that I have used in the past that might help you out:

However, there are some aspects of your 'two questions' that are a bit confusing/concerning. Hopefully I'm misinterpretting what you've said, but keep the following in mind:

  1. With your first question, I think you might be getting caught up on the physical location of the source code on your development machine and how your repositories will be structured (hint: treat the two separately).
  2. In your second question, you mention specific references and it sounds like you might be thinking of making your API in some way dependent on the website source (hint: bad idea for an API).
dwightgunning
I see - yes that sounds right, I will make a change in my thinking - The API code does need to be separate. Thank you for the links :0)
Matt1776
+1  A: 

I think you can use svn:externals to achieve what you want. It will pull the library project into your website project and update it whenever you update your working copy. The only thing is you cannot commit back to the library in the same commit as you project as described in this question http://stackoverflow.com/questions/2336790/how-do-i-checkin-to-local-copy-and-svnexternals-subdirectories-in-one-commit.

jondro
This looks like the answer - if this works the way I think it does I can modify the library at the same time as my web project and in consideration of dwight's suggestion I can branch this code making the two clean and separate. Thank you :)
Matt1776