{{TOC}}
= Introduction =
The Bug Genie uses an MVC framework, heavily inspired by the [http://symfony-project.org Symfony framework]. The Bug Genie tries to follow the MVC separation strictly, and borrows several well known concepts from the Symfony framework. If you've worked with this framework before, files such as ''actions.class.php'' and the [[TheBugGenie:Development:Routing|routing]] system should be familiar concepts.

= Directory hierarchy =
 thebuggenie
   - core
     - B2DB
     - classes
       - B2DB
     - lib
     - templates
   - modules
     - main
       - classes
         actions.class.php
       - templates
         index.html.php
   - thebuggenie
     - css
     - js
     - themes
       - oxygen

= Class autoloading =
The Bug Genie has a class autoloading mechanisms that will look for classes in specific folders and files. Following recommended php coding conventions, classes are expected to be found in the file '''Classname.class.php'''. The Bug Genie will look for classes in the following directories:
* core/classes
* modules/<modulename>/classes
In addition, any B2DB (table-) classes are expected to be found in a '''B2DB''' subdirectory under the '''classes''' folder. You're free to put them in the '''classes''' folder directly, but for consistency, B2DB classes are located in ''core/classes/B2DB'' and ''modules/<modulename>/classes/B2DB''.

If you have any special classes, interfaces or Exception classes you want to include specifically before any other classes, The Bug Genie will look for a file called ''generics.class.php''. If this file is found, it will be automatically be included before any autoloading takes place.

== Adding class-paths to the autoloader ==
As mentioned above, The Bug Genie will automatically look through the ''classes'' directory in your module directory. If you want to add any other directories to the autoloader, use the static method '''addClasspath()''' in '''TBGContext'''.

Example:
<source lang="php">
TBGContext::addClasspath('/my/valid/path/');
</source>
This will add the path to The Bug Genies class autoloader. Usually this is not necessary, but may be desired for some external libraries or classes.

== Actions and components classes ==
Every module that uses routes is expected to have an [[TheBugGenie:Development:Actions|actions]] class, named '''ModulenameActions''', which should extend the '''[[TheBugGenie:Development:Actions|TBGAction]]''' class. This special class is saved in the file ''actions.class.php'' inside the classes directory, and is autoloaded if it exists.

If your module uses [[TheBugGenie:Development:Components|components]], you will have to create a components class '''ModulenameActionComponents''', extending the '''TBGActionComponent''' class (Notice the plural form in the child classes).

Examples:
'''my_module/classes/actions.class.php''':
<source lang="php">
/**
 * Example actions class for mymodule
 */
class mymoduleActions extends TBGAction
{

	/**
	 * Index action
	 *  
	 * @param TBGRequest $request
	 */
	public function runIndex(TBGRequest $request)
	{
	}

}
</source>

'''my_module/classes/actioncomponents.class.php''':
<source lang="php">
/**
 * Example components class for mymodule
 */
class mymoduleActionComponents extends TBGActionComponent
{

	/**
	 * Menu component
	 */
	public function componentMenu()
	{
	}

}
</source>

= Templates =
Core template files are located in the ''core/templates'' folder. The templates there are the ones decorating every page, the header, menu and the footer. If you ever want to change the global header, menu or footer, edit the template files located here. Keep in mind that these template files may be overwritten on updates, so back up your changes before you update to newer versions.

== Module templates ==
Module templates are found in the ''modulename/templates'' folder. This is also where component templates and partial templates are found. Main templates (associated with an action) are called (lowercase) ''<actionname>.<format>.php'', whereas template partials and component templates are called (lowercase) ''_<componentname>.inc.php'' and ''_<templatename>.inc.php''. Notice the difference, with both a leading underscore, and the ''.inc.php'' extension.

Example (template file for the ''runIndex()'' action above, standard html version):
 thebuggenie
 - modules
   - mymodule
     - templates
       index.html.php

Example (template file for the ''componentMenu()'' component above):
 thebuggenie
 - modules
   - mymodule
     - templates
       _menu.inc.php

For a more detailed explanation about [[TheBugGenie:Development:Templates|templates]], [[TheBugGenie:Development:Components|components]] and [[TheBugGenie:Development:TemplatePartials|template partials]], see their respective documentations.



[[Category:TheBugGenie:Development]]