title: Component based web project directory layout with git and symlinks
body: <p>I am planning my directory structure for a linux/apache/php web project like this:</p>
  
  <p>Only <code>www.example.com/webroot/</code> will be exposed in apache</p>
  
  <pre><code>www.example.com/
    webroot/
      index.php
      comp1/
      comp2/
    component/
      comp1/
        comp1.class.php
        comp1.js
      comp2/
        comp2.class.php
        comp2.css
    lib/
      lib1/
        lib1.class.php
  </code></pre>
  
  <p>the <code>component/</code> and <code>lib/</code> directory will only be in the php path. </p>
  
  <p>To make the css and js files visible in the webroot directory I am planning to use symlinks.</p>
  
  <pre><code>  webroot/
      index.php
      comp1/
        comp1.js (symlinked)
      comp2/
        comp2.css (symlinked)
  </code></pre>
  
  <p>I tried following these principles:</p>
  
  <ul>
  <li>layout by components and libraries, not by file type and not by "public' or 'non public', index.php is an exception. This is for easier development. </li>
  <li>expose onle the minimal set of files in a public web directory and make everything else unaccesable to the web. Symlinking files that need to be public for the components and libs to a public location, but still mirroring the layout. So the component and library structure is also visible in the resulting html code in the links, which might help development.</li>
  <li>git usage should be safe and always work. it would be ok to follow some procedure to add a symlink to git, but after that checking them out or changing branches should be handled safely and clean</li>
  </ul>
  
  <p>How will git handle the symlinking of the single files correctly, is there something to consider? </p>
  
  <p>When it comes to images I will need to link directories, how to handle that with git?</p>
  
  <pre><code>  component/
      comp3/
        comp3.class.php
        img/
          img1.jpg
          img2.jpg
          img3.jpg
  </code></pre>
  
  <p>They should be linked here:</p>
  
  <pre><code>  webroot/
      comp3/
        img/ (symlinked ?)
  </code></pre>
  
  <p>If using symlinks for that has disadvantages maybe I could move images to the webroot/ tree directly, which would break the first principle for the third (git practicability).</p>
  
  <p>So this is a git and symlink question. But I would be interested to hear comments about the php layout, maybe you want to use the comment function for this.</p>