Chapter 5. Configuration

Table of Contents

Bootsrapping
Custom directory structure
Pre and post dispatch files
Custom error pages

Bootsrapping

Atomik provides a default configuration for everything (to fullfill the convention over configuration principle). However, you can override it and provide plugin's configuration or even your own.

To do so, there is two possibilities:

  • modify Atomik's core file (index.php)
  • create a bootstrap.php file in the app directory.

The first method is greatly discourage. It can however be useful if you want to create your own Atomik distribution (this should be the only reason to use this method).

The second method is of course the prefered one. It allows clearer configuration in a unique place, perfect for maintenance. Just create a bootstrap.php file in the app directory. In this file, you can use accessors (the set method of course) to define configuration keys.

Example 5.1. Exemple bootstrap.php file

				
<?php

/* configuration */
Atomik::set(array(

	'key1' => 'value1',
	
	'key2' => value2',
	
	'key3' => array(
	
		'key3.1' => 'value3.1'
	
	)

));
			

The name of this file can be changed using the atomik/files/bootstrap configuration key.

Custom directory structure

As said in the installation chapter, the directory structure can be customized. This can be done by modifying entries in the atomik/dirs configuration key.

Figure 5.1. The default configuration for directories

The default configuration for directories

Each keys in the dirs array represent a type of directory. Their value can be a string for a single path or an array for mutliple paths.

Pre and post dispatch files

Atomik allows you to create to files: pre_dispatch.php and post_dispatch.php in the app directory. These files will be called respectively before and after the dispatch process.

Their filename can be changed using the atomik/files/pre_dispatch and atomik/files/post_dispatch configuration keys.

Custom error pages

Whem an error occures, Atomik will display an error report. You can instead display a custom error page. Create a file named error.php in the app directory.

The content can be anything you want. Beware that the layout won't be applied on this page. You also have access to a variable named $exception which contains the thrown exception.

It is also possible to customize 404 error pages. Just create a 404.php file in the app directory. Like the error page, the layout won't be applied.

The filename of these files can be changed using the atomik/files/error and atomik/files/404 configuration keys.