How can I configure a database connection?

Open application/{custom_dir}/config/databases.ini, uncomment the [default] section and make any change required or add a whole new section of your own.

How can I ensure the connection to the database server is established when the application loads?

Go to the application/hooks/ directory and insert code to connect to the db in one of the following hook files:

Mode File
for CLI and Web modes before_run.php
for CLI mode only cli_before_run.php
for Web mode only http_before_run.php

The code to connect to a MySQL db is as simple as:

$this->lib->mysql->configure('your_connection_section_name'); // usually [DEFAULT] unless you changed it

In normal operations, the mysql class library connects to the database server only when the first query has to be executed.

This default behaviour is best if some parts of your application do not use the db. This could even save you a db connect operation in the best case.

On the other hand, this is inconvenient if your application heavily depends on the db. In this case, you'll probably want to ensure the db is reachable as soon as the application loads. To this end, we recommend you use the early connection technique described above.

How can I install more than one application on the same site?

As explained above, each application must have its own 'custom' directory but also its own 'index.php' and '.htaccess'.
Consequently, each application much be installed in a separate directory. In case of web applications, this means creating a sub-site for each of these applications. To do this you have to copy the 'application' template directory into the root directory of each sub-site and apply the configuration instructions described above for each one of them.
This includes the change to 'base_url' and to the RewriteBase rule in .htaccess which now becomes required steps.

How can I use colored text output in CLI mode?

Under Windows, you are out of luck, since colored text is not supported. Under Linux, it is enabled by default.
To know whether colored text is enabled on your system you can call:


This function will return a "true" or "false" value reflecting your OS level of support.
To output colored text, use a call similar to this:

$this->lib->cli->out('Hello', 'yellow');

What is a module?

A module is a just class in the addon package that can be used only in this addon. For example, you can create a module for working with the database, an other module for working with files and yet an other module for working with some functions.
As another example, if you build a website with administrator area, you can write a 'news' addon, with one module for the backend (the administrator end) and another module for frontend (the users end) functionality.
In other words, the addon functionality is implemented in one main addon and some specific module classes.

What is an addon?

An addon in toKernel is the combination of model, view, controler classes found in other frameworks but with some additional components.
Each addon has one main controller class, named home.addon.php where class home_addon extends addon { ... } or class other_home_ext_addon extends home_addon { ... } Each addon class can have as many modules as required!

Where can I define constants for the whole application?


Where is the application configuration file?

The application main configuration file is application.ini, located in application/{custom_dir}/config/ directory.

Example: /var/www/my_custom_app/config/application.ini

And there also other configuration files like databases.ini, aliases.ini located in same directory.