Search code examples
phpeclipsegitsvnworkspace

How to organize my workspace and working copy


i need an advice on how organize my files and folders.
First of all, i'm working under Windows 7 64-bit, using PHP as language and Eclipse as IDE.

I used to have all my works under a folder, so i can checkin / out with a simple click on the root. More over, all of my projects need to be under the XAMPP path, that's something like J:\XAMPP\htdocs\my_project.

This is my Dev Folder:

MyProject
  `- trunk
    `- component
      `- backend
      `- frontend
    `- modules
      `- mod_myproject
    `- plugins
MyProject2
  `- etc. etc.

And everything should go in the right place, ie:

J:\xampp\htdocs\myproject1
    administrator
      `- components
        `- com_myproject        (refers to trunk/component/backend)
    components
      `- com_myproject          (refers to trunk/component/frontend)
    modules
      `- mod_myproject          (refers to trunk/modules/mod_myproject)

How can i organize everything so i can have both my "dev folder" and "workspace folder" updated?

Here there are some infos:

  • I can't register my files to autoload using PHP function
    That's why i'm a Joomla! developer and every extension has its path; files need to be in that place.
  • I can't use symlinks
    I really don't know why, but with symlinks I can't use Xdebug to debug my code on these files, and of course I really need what's going on my component
  • I'd wish to avoid copy scripts
    I had an Ant script, until someday I launched the deploy script instead of the commit one. Half day of work wasted with a click -.-
  • SVN or GIT
    Even if i'm not a pro with these CVS, I can use both, so there is no difference between using one instead one another one.

I really need an advice, since I feel I'm doing it wrong..


Solution

  • OK, well, here is how I would do it, but of course YMMV.

    As you are using Eclipse, you can use ant (nobody said ant was for Java only, heh).

    If you use git, you have the often-overlooked, but oh so useful, git archive command.

    This example requires that you have git in your path somewhere (either with cygwin or msysgit, I happen to prefer cygwin).

    So, let's make an ant macro in the build.xml file:

    <property name="zipout" location="/some/path"/>
    
    <macrodef name="git-deploy">
        <attribute name="src"/>
        <attribute name="dst"/>
        <attribute name="refspec" default="HEAD"/>
        <sequential>
            <exec executable="git" failonerror="true" output="${zipout}/archive.zip">
                <arg value="archive"/>
                <arg value="--format=zip"/>
                <arg value="--prefix=@{dst}/"/>
                <arg value="@{refspec}:@{src}"/>
            </exec>
            <unzip src="${zipout}/archive.zip" dest="/path/to/htdocs"/>
            <delete file="${zipout}/archive.zip"/>
        </sequential>
    </macrodef>
    

    You could then use this macro from the root of your dev directory with:

    <git-deploy src="trunk/component/backend" refspec="somebranch"
        dst="administrator/components/com_myproject"/>
    

    You can then define a properties file to source in order to define your zipout, path to htdocs etc and use them in the macro as well.