Chapter 9. Includes

Includes are php files containing common logic that you include in your actions.

Includes are stored in the app/includes and/or the app/libraries directories.

To include a file from one of these directories use the Atomik::needed() method. It takes as first argument the path to the filename you wish to include relative to the previous directories and without the extension.

Example 9.1. Using includes

Let's say we've created the file app/includes/common.php


You can use sub directories. To include a file stored at app/includes/libs/db.php:


Atomik::needed() also allows you to include classes using their name. To do so, classes have to follow the PEAR naming convention (

Example 9.2. Including classes with their name

Let's include the class Atomik_Db located in app/libraries/Atomik/Db.php



Atomik::needed() is automatically registered as an spl_autoload handler. This can be modified by setting “false” to the configuration key named “atomik/class_autoload”.