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
comp1/
comp2/
component/
comp1/
comp1.class.php
comp1.js
comp2/
comp2.class.php
comp2.css
lib/
lib1/
lib1.class.php
the component/
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
comp1/
comp1.js (symlinked)
comp2/
comp2.css (symlinked)
I tried following these principles:
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?
component/
comp3/
comp3.class.php
img/
img1.jpg
img2.jpg
img3.jpg
They should be linked here:
webroot/
comp3/
img/ (symlinked ?)
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).
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.
As soon as you need to reuse some set of files elsewhere, that's when you should start thinking in term of components or (in git) submodules
Instead of managing webroot
, and comp
, and lib
within the same repo (which is the SVN or the "Centralized way" for CVCS), you define:
img
' would be a Git repo reused as a submodule within webroot
, for instance)That is one of advantages of submodules of symlink: you reference one exact revision, and if that component has some evolutions of its own, you don't see them immediately (not until you update your submodule anyway).
With a symlink, you see whatever state is the set of files at the other end of that link.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With