Working as a freelance developer I have very little time to waste. This article explains how I setup my project directory and why. I also include a bash script which automatically generates the working directories.

I do all my development on a Linux desktop because it gives me quick and easy access to the tools I need to automate my development. The following structure relies on the use of SVN and symbolic links. I'll explain how I use each directory to organize my project.

This is the directory structure I use:

  • html
  • resources
    • css
    • js
    • template
    • images
  • scripts
  • sql
  • mockups
  • apache

html

The html directory I use for the public portion of the website. This will be the directory you set Apache to show as root. The idea here is to install your CMS (such as Joomla, WordPress, ExpressionEngine, Drupal) or your framework (such as CodeIgniter or Cakephp) or any other web app you plan to run.

Keeping your CMS separate allows you to run easy updates or installs of newer versions or your site. You can also checkout a project from their already maintained repository. Keeping the CMS separate stops you from modifying the core, which will be a nightmare when security updates are released.

resources

The directories image, css and js are pretty straight forward. What you are going to do is symbolically link these directories into your html folder. Most of your time developing will be in this directory.

The templates directory contains the templates (aka themes) of your CMS. This is an optional directory especially if your using a framework.

scripts

The scripts directory is where you are going to keep all of your bash scripts and database migrations. This includes the a configuration bash script which symbolically links your resources directories to your html directory.

sql

This is where I store sql files. Storing a dump of your database here can come in real handy when doing backups or updating svn.

mockups

Mockups is what I refer to as my source images. Images are updated frequently and I like to place them in version control.

apache

When switching between development servers, grid servers and Virtual Private Servers I like to keep a copy of my apache2 config files handy. This really only works with Apache 2. Having a copy of my config file in svn allows me to rapidly deploy websites to different servers by using existing scripts.

Build Project Directory Script

Here is the script that will create these directories. Yea I'm that lazy

#!/bin/bash
# Build Project Directories
# v1.2
# Last Updated: Jun 3, 2009
# Documentation: 
# http://www.nickyeoman.com/blog/system-administration/18-project-directory-setup

mkdir html scripts sql mockups apache 
mkdir -p resources/{css,js,template,images}

I know I can do the above on one line, but wanted to make it easy for you to read.

Thanks

I'd like to thank:

Help Me Out

Do you know of a better way for me to do this? I'd love to hear from you.

Comments

Show/Hide Comment form