Module based web project directory layout with git and symlinks

Posted by karlthorwald on Stack Overflow See other posts from Stack Overflow or by karlthorwald
Published on 2010-05-24T12:29:13Z Indexed on 2010/05/24 12:31 UTC
Read the original article Hit count: 337

Filed under:
|
|

I am planning my directory structure for a linux/apache/php web project like this:

Only www.example.com/webroot/ will be exposed in apache

www.example.com/
  webroot/
    index.php
    module1/
    module2/
  modules/
    module1/
      module1.class.php
      module1.js
    module2/
      module2.class.php
      module2.css
  lib/
    lib1/
      lib1.class.php

the modules/ and lib/ directory will only be in the php path.

To make the css and js files visible in the webroot directory I am planning to use symlinks.

  webroot/
    index.php
    module1/
      module1.js (symlinked)
    module2/
      module2.css (symlinked)

I tried following these principles:

  • layout by modules and libraries, not by file type and not by "public' or 'non public', index.php is an exception. This is for easier development.
  • symlinking files that need to be public for the modules and libs to a public location, but still mirroring the layout. So the module structure is also visible in the resulting html code in the links, which might help development.

How will git handle the symlinking of the single files correctly, is there something to consider?

When it comes to images I will need to link directories, how to handle that with git?

  modules/
    module3/
      module3.class.php
      img/
        img1.jpg
        img2.jpg
        img3.jpg

They should be linked here:

  webroot/
    module3/
      img/ (symlinked ?)

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.

© Stack Overflow or respective owner

Related posts about linux

Related posts about git