This past week, I was handed a Joomla site developed by someone else, and I was asked to clean up and update a few sections on the site. At first glance, I just about died. The file system was a mess—multiple Joomla installs, assets spread across different directories, everything out of place—and the internal structure (database) was no better. We tracked down the correct files using WebKit’s developer tools, but we could have saved significant time if the site was better organized.
Everyone already knows that keeping your projects well-organized streamlines development. makes collaborating with others easier, and allows you to keep your sanity should you have to come back to a project weeks, months, or even years, after completing it. Right?
How do you keep your project folders organized when creating web sites/apps? Read on for my organization strategy, and then leave yours in the comments.
Organization at a glance
To get started, here’s how I organize mine:
Getting into the nitty-gritty…
Each client gets it’s own directory on my server, and each project gets its own directory underneath the client its specifically built for.
Version control. Everyone should use some flavor of version control. It doesn’t matter whether you use git, subversion, mercurial… just use it and stop complaining about having to learn something new.
For custom PHP projects, CodeIgniter apps, and ExpressionEngine installs, I put all of my app logic into subdirectories contained within the app directory; keeping this data out of the docroot helps keep me organized and gives an extra layer of security.
I use this directory to keep all of my needed configuration files for any scripts, application settings, and even hosting configs (if I’m running nginx, I’ll drop a symlink to this host’s specific configuration file.) Again, config files kept away from the docroot is a nice boost for security.
If I’m exporting data out of my web app as a file, I’ll usually export it to this directory. When a user needs to download it from the site, I’ll have PHP fetch the file and return it. Keeps export files safe from prying eyes and allows me to use whatever authentication scheme I’m using to allow/deny access to these files.
Usually, I’ll build the project’s front end code out separately from the app logic. If so, I keep those original files here and stashed in the repository for easy reference later on.
Application specific logs go here as well as symlinks to any domain-specific host access and error logs.
My docroot for each project. I try to limit files going in here to only what’s needed (final front end assets like js/css/images, static html, etc.).
Deployment scripts, front-end testing JS (for large forms that require repetitive data entry).
That’s how I do it. Et tu?
Do you use a similar strategy? Maybe something completely different? Leave your strategies and ideas on organization in the comments, and let’s get organized.