Directory Structure

Finding your way around a Wheels application.

After downloading and unzipping Wheels, here's the directory structure that you will see (plus signs indicate folders):

  • + config
  • + controller
  • + events
  • + files
  • + images
  • + javascripts
  • + model
  • + stylesheets
  • + view
  • + wheels
  • .htaccess
  • Application.cfc
  • index.cfm
  • IsapiRewrite4.ini
  • rewrite.cfm
  • root.cfm

Quick Summary

Your configuration settings will be done in the config directory.

Your application code will end up in four of the folders, namely controllers, events, models, and views.

Static media files should be placed in the files, images, javascripts and stylesheets folders.

And the last directory? That's the framework itself. It exists in the wheels directory. Please go in there and have a look around. If you find anything you can improve or new features that you want to add, send us a patch!

Detailed Overview

Let's go through all of the files and directories now starting with the ones you'll spend most of your time in: the code directories.

controllers

This is where you create your controllers. You'll see one file in here already: Controller.cfc. You can place functions inside Controller.cfc to have that function shared between all the controllers you create. (This works because all your controllers will extend Controller.)

models

This is where you create your model files (or classes if you prefer that term). Each model file you create should map to one table in the database.

The setup in this directory is similar to the one for controllers, to share methods you can place them in the existing Model.cfc file.

views

This is where you prepare the views for your users. As you work on your website, you will create one view directory for each controller.

Before doing that though, you already have one directory: layouts. This is where you will place your layout files and/or change the default.cfm layout file.

events

If you want code executed when ColdFusion triggers an event, you can place it here (rather than directly in Application.cfc).

config

Make all your configuration changes here. You can set the environment, routes, and other settings here. You can also override settings by making changes in the individual settings files that you see in the subdirectories.

files

Any files that you intend to deliver to the user using the sendFile() function should be placed here. Even if you don't use that function to deliver files, this folder can still serve as storage if you like.

images

This is a good place to put your images. It's not required to have them here, but all Wheels functions that involve images will, by convention, assume they are stored here.

javascripts

This is a good place to put your JavaScript files. By default, there are two there already: application.js and protoculous.js.

If all you need is one file for your own Javascripts, you can use application.js. The only real advantage to using this is that you'll have to write slightly less code when including scripts in your HTML later on since it's part of the Wheels defaults.

The protoculous.js file is used internally by Wheels, so leave it in there if you intend to use any Wheels functions involving AJAX and JavaScript effects.

stylesheets

This is a good place to put your CSS files. This is set up similarly to the javascripts folder in that there is a default file in there already that you can use.

wheels

This is the framework itself. When a new version of Wheels is released it is often enough to just drop it in here (unless there has been changes to the general folder structure).

.htaccess

This file is used by Apache, and you specifically need it for URL rewriting to work properly. If you're not using Apache, then you can safely delete it.

IsapiRewrite4.ini

If you use IIS and want to use URL rewriting, you'll need this file. Otherwise, you can safely delete it.

Application.cfc, index.cfm, and rewrite.cfm

These are all needed for the framework to run. No changes should be done to these files.

You can add more directories if you want to, of course. Just remember to include a blank Application.cfc in those directories. Otherwise, Wheels will try to get itself involved with those requests as well.