Skip to content

Developer Guide: File Naming Conventions

ginatrapani edited this page Sep 13, 2010 · 5 revisions

When creating new files, here’s where to put them and what to name them.

ThinkTank’s Folder Structure

Wondering what a folder is and contains? Here’s a rundown.

  • /thinktank/extlib/ – Contains external libraries that ThinkTank depends on, like Smarty
  • /thinktank/extras/ – Contains “extra” ThinkTank helper scripts, like cron scripts, the WordPress plugin, and more
  • /thinktank/logs/ – ThinkTank’s crawler and slow SQL logs
  • /thinktank/sql/ – Database build and migration scripts
  • /thinktank/tests/ – ThinkTank’s regression tests
  • /thinktank/webapp/ – ThinkTank’s main application folder, which should be exposed on the web via copy or symlink

The webapp folder contains several key folders:

  • /webapp/controller/ – Contains ThinkTank’s controllers
  • /webapp/model/ – Contains ThinkTank’s model objects
  • /webapp/plugins/ – Contains ThinkTank’s plugin files
  • /webapp/crawler/ – Contains ThinkTank’s data crawler
  • /webapp/view/ – Contains ThinkTank’s view files, its Smarty templates

In the webapp folder, there are two key files:

  • config.inc.php – ThinkTank’s single, main, configuration file
  • init.php – Every controller page includes this file, which includes all the model objects and initializes global variables

Classes

ThinkTank-wide class files should be located in the /thinktank/webapp/model/ folder, with the filename class.ClassName.php. The class and the DAO class should both appear in this file.

For example, the Post and Post DAO objects are in the /thinktank/webapp/common/class.Post.php file.

Plugin classes should be located in the /thinktank/webapp/plugins/pluginname/lib/ directory, using the same naming convention.

Templates

ThinkTank-wide templates are located in /thinktank/webapp/templates/ with the .tpl file extension. The template name should match the file name which calls it. Use dots to represent folders.

For example, the public.php file calls the public.tpl template.

The account/index.php file calls the account.index.tpl template.

Included template filenames should start with an underscore. For example, the header template is named _header.tpl.

Tests

There are three basic types of tests: DAO tests, Webapp tests, and plugin tests.

TODO: Come up with naming convention for each.

Test Data

Right now a dash represents a slash in test data file names.

TODO: Come up with file name conventions with appropriate replacements for /, ?, &, and =

Clone this wiki locally