Modules

Bonfire includes a Modules library to supplement the modules functionality included in Wiredesignz HMVC.

Methods

Many of these methods are intended for internal use, but are public for backwards-compatibility.

run($module)

Run a module controller method (as indicated by $module).
Output from module is buffered and returned.

  • If $module contains a slash, it will be split into $module/$method.
  • If additional parameters are passed to Modules::Run(), they will be passed to the method indicated by $module.

Returns either a directly returned value from the method or the buffered output of the method.
If the method was not found, an error is logged and nothing is returned.

load($module)

Loads a controller in a module.
If $module is an array, the first item in the array will be used for $module, and the remaining items will be used as parameters to be passed to the method.

Returns the loaded controller, or nothing if the controller was not found.

autoload($class)

Handles autoloading core and library classes using MX_ and BF_ prefixes, along with the CI_ and 'subclass_prefix'.

This method is registered with PHP as an autoloader when the Modules library is loaded.

load_file($file, $path[, $type = 'other'[, $result = true]])

Load a module file.
- $file is the name of the file to load.
- $path is the path to the file.
- $type is the type of file, usually 'lang', 'config', or 'other' (default).
- $result is the value which will be returned, unless $type is not 'other'.

If $type is 'lang' or 'config', the value of $lang or $config will be returned.

find($file, $module, $base)

Find a file.
Looks for the file within module and application directories.
- $file is the file to be found.
- $module is the module in which the file should be located.
- $base is the type of file ('models', 'plugins', 'views', etc.).

Returns an array with the first entry containing the full path and the second entry containing the file name.
If the file was not found, the first entry in the array will be false.

parse_routes($module, $uri)

Parse a routes file for a module (from the module's config/routes.php file) to locate a route for a given URI.
- $module is the module in which the routes file should be located.
- $uri is the URI to be found in the routes file.

Returns the parsed route, if found, or nothing.

controller_exists($controller, $module)

Determine whether a controller ($controller) exists in a given module ($module).
$controller must not include the file extension (.php).

This method will return false if either $controller or $module is empty, or if the $controller was not found in the $module.
Otherwise, it will return true (if the $controller was found in the $module).

file_path($module, $folder, $file)

  • $module The module in which the file should be located.
  • $folder The folder within the module to search for the file (e.g. 'controllers').
  • $file The name fo the file to search for (including the .php extension).

Returns the path to a file within a module, if it can be found.
If $module, $folder, or $file is empty, returns false.
If the file is not found, nothing is returned.

path($module[, $folder = null])

  • $module The name of the module (must match the name of the module's directory).
  • $folder The name of the folder to find within the module's directory.

Return the path to the specified folder within the specified module.
If the folder could not be found, the module's directory is returned.
If the module could not be found, nothing is returned.

files([$module_name = null[, $module_folder = null[, $exclude_core = false]]])

Retrieve a list of files within one or more modules.
- $module_name If not null, will return only files from this module.
- $module_folder If not null, will return only files within this sub-folder (e.g. 'config').
- $exclude_core If true, excludes Bonfire (core) modules.

Returns an associative array of files found in the format:

array(
    'module_name' => array(
        'folder' => array('file1', 'file2')
    )
)

If no files were found, returns false.

config($module_name[, $return_full = false])

Returns the 'module_config' array from a module's config/config.php file.
This array can be used for custom fields in addition to fields used to supply information to Bonfire for the admin UI.

  • $module_name The name of the module for which the config data will be retrieved.
  • $return_full If true and 'module_config' is not found, the entire config array will be returned.

  • Returns an empty array if:

    • the config file was not found,
    • $config is not set after including the config file, or
    • 'module_config' is not set and:

      • $return_full is false, or
      • $return_full is true and $config is not an array.
  • If 'module_config' is not set, $return_full is false, and $config is an array, the value of $config is returned.
  • Otherwise, the value of 'module_config' is returned.

folders()

Returns an array of the folders in which modules may be stored (these are absolute paths).

list_modules([$exclude_core = false])

Returns a list of modules in the system.

If $exclude_core is true, the Bonfire (core) modules will not be included in the list.

The returned array will contain the names of the folders within the module directories.

Properties

All of these properties are intended primarily for internal use, but are public for backwards compatibility.
In most cases, one or more of the methods will return the information contained in these properties.

$locations

An array of module locations, normally retrieved from the 'modules_location' setting in the site's config/application.php file.
The array keys are the canonicalized absolute paths to the modules directories.
The values are relative paths.

The Modules library only uses the keys internally.

$registry

A registry of loaded controllers.
The keys are the names of the controllers in lowercase.
The values are controller instances.

$routes

An array of module routes, with the module name as the key and the routes for that module (loaded from the module's config/routes.php file) as the value.

Profiler
Profiler Console 0 Load Time 11.4ms Memory Used 0.88 MB Database 4 Queries vars & Config Files 87

Console

Memory Usage

Benchmarks

1 ms Loading Time: Base Classes
8 ms Controller Execution Time ( Docs / Index )
11 ms Total Execution Time

Queries

0.0001 SELECT GET_LOCK('1694784247aa4919403a2807270f7481', 300) AS ci_session_lockSpeed: 0.0001 - Possible keys: - Key Used: - Type: - Rows: - Extra: No tables used
0.0002 SELECT `data` FROM `bf_ci_sessions` WHERE `id` = '4pcjptsr1ii0lascp3gm26so1rg68mip' and `ip_address` = '3.23.103.203'Speed: 0.0002 - Possible keys: - Key Used: - Type: - Rows: - Extra: Impossible WHERE noticed after reading const tables
0.0002 SHOW TABLES FROM `bonfire`
0.0002 SELECT * FROM `bf_settings`Speed: 0.0002 - Possible keys: - Key Used: - Type: ALL - Rows: 42 - Extra:
0.0008 Total Query Execution Time

Session User Data

__ci_last_regenerate 1734911468
requested_page https://kampensonline.com/docs/developer/modules
previous_page https://kampensonline.com/docs/developer/modules

GET DATA

No GET data exists

POST DATA

No POST data exists

URI STRING

docs/developer/modules

CLASS/METHOD

docs/index

HTTP HEADERS

HTTP_ACCEPT */*
HTTP_USER_AGENT Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
HTTP_CONNECTION
SERVER_PORT 443
SERVER_NAME kampensonline.com
REMOTE_ADDR 3.23.103.203
SERVER_SOFTWARE Apache/2.4.62 (Ubuntu)
HTTP_ACCEPT_LANGUAGE
SCRIPT_NAME /index.php
REQUEST_METHOD GET
HTTP_HOST
REMOTE_HOST
CONTENT_TYPE
SERVER_PROTOCOL HTTP/1.1
QUERY_STRING
HTTP_ACCEPT_ENCODING gzip, br, zstd, deflate
HTTP_X_FORWARDED_FOR

CONFIG VARIABLES

domain kampensonline.com
base_url https://kampensonline.com
index_page
uri_protocol AUTO
url_suffix
language english
charset UTF-8
enable_hooks true
subclass_prefix MY_
composer_autoload false
permitted_uri_chars a-z 0-9~%.:_-
allow_get_array true
enable_query_strings false
controller_trigger c
function_trigger m
directory_trigger d
log_threshold 4
log_path /var/www/htdocs/bonfire/application/logs/
log_file_extension
log_file_permissions 436
log_date_format Y-m-d H:i:s
error_views_path
cache_path /var/www/htdocs/bonfire/application/cache/
cache_query_string false
encryption_key 92b35b02920621aedbed3b8b9a68c0f1
sess_cookie_name bf_session
sess_expiration 7200
sess_time_to_update 300
sess_match_ip true
sess_driver database
sess_regenerate_destroy false
sess_save_path ci_sessions
cookie_prefix
cookie_domain kampensonline.com
cookie_path /
cookie_secure false
cookie_httponly true
cookie_samesite Strict
standardize_newlines false
csrf_protection true
csrf_token_name ci_csrf_token
csrf_cookie_name ci_csrf_token
csrf_expire 7200
csrf_regenerate true
csrf_exclude_uris Array ( )
compress_output false
time_reference local
rewrite_short_tags false
proxy_ips
bonfire.installed 1
site.default_user_timezone UP12
modules_locations Array ( [/var/www/htdocs/bonfire/application/modules/] => ../../application/modules/ [/var/www/htdocs/bonfire/bonfire/modules/] => ../../bonfire/modules/ )
site.backup_folder archives/
contexts Array ( [0] => content [1] => reports [2] => settings [3] => developer )
enable_activity_logging true
sparks_path ../sparks/
template.site_path /var/www/htdocs/bonfire/public/
template.theme_paths Array ( [0] => themes )
template.default_layout index
template.ajax_layout ajax
template.use_mobile_themes false
template.default_theme default/
template.admin_theme admin
template.message_template <div class="alert alert-{type} alert-dismissable"> <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button> <div>{message}</div> </div>
template.breadcrumb_symbol :
template.parse_views false
assets.directories Array ( [base] => assets [cache] => cache [css] => css [image] => images [js] => js [module] => module )
assets.js_opener $(document).ready(function() {
assets.js_closer });
assets.css_combine false
assets.js_combine false
assets.css_minify true
assets.js_minify true
assets.encrypt_name false
assets.encode false
assets.base_folder assets
assets.asset_folders Array ( [css] => css [js] => js [image] => images )
ui.current_shortcuts Array ( [form_save] => Array ( [description] => Save any form in the admin area. [action] => $("input[name=save]").click();return false; ) [create_new] => Array ( [description] => Create a new record in the module. [action] => window.location.href=$("a#create_new").attr("href"); ) [select_all] => Array ( [description] => Select all records in an index page. [action] => $("table input[type=checkbox]").click();return false; ) [delete] => Array ( [description] => Delete the record(s). [action] => $("#delete-me.btn-danger").click(); ) [module_index] => Array ( [description] => Return to the index of the current module. [action] => window.location.href=$("a#list").attr("href"); ) [goto_content] => Array ( [description] => Jump to the Content context. [action] => window.location.href=$("#tb_content").attr("href") ) [goto_reports] => Array ( [description] => Jump to the Reports context. [action] => window.location.href=$("#tb_reports").attr("href") ) [goto_settings] => Array ( [description] => Jump to the Settings context. [action] => window.location.href=$("#tb_settings").attr("href") ) [goto_developer] => Array ( [description] => Jump to the Developer context. [action] => window.location.href=$("#tb_developer").attr("href") ) )
emailer.write_to_file false
migrate.auto_core false
migrate.auto_app false
commonmark.valid_drivers Array ( [0] => Parsedown [1] => Markdown [2] => MarkdownExtra [3] => LeagueCommonMark )
commonmark.driver MarkdownExtended
docs.theme docs
docs.default_group developer
docs.show_dev_docs true
docs.show_app_docs true
docs.toc_file _toc.ini
docs.permitted_environments Array ( [0] => development [1] => testing [2] => production )

Files

application.php
/var/www/htdocs/bonfire/application/config/application.php
autoload.php
/var/www/htdocs/bonfire/application/config/autoload.php
config.php
/var/www/htdocs/bonfire/application/config/config.php
constants.php
/var/www/htdocs/bonfire/application/config/constants.php
database.php
/var/www/htdocs/bonfire/application/config/database.php
events.php
/var/www/htdocs/bonfire/application/config/events.php
hooks.php
/var/www/htdocs/bonfire/application/config/hooks.php
mimes.php
/var/www/htdocs/bonfire/application/config/mimes.php
profiler.php
/var/www/htdocs/bonfire/application/config/profiler.php
routes.php
/var/www/htdocs/bonfire/application/config/routes.php
Base_Controller.php
/var/www/htdocs/bonfire/application/core/Base_Controller.php
MY_Model.php
/var/www/htdocs/bonfire/application/core/MY_Model.php
App_hooks.php
/var/www/htdocs/bonfire/application/hooks/App_hooks.php
application_lang.php
/var/www/htdocs/bonfire/application/language/english/application_lang.php
Profiler.php
/var/www/htdocs/bonfire/application/libraries/Profiler.php
Base.php
/var/www/htdocs/bonfire/application/third_party/MX/Base.php
Config.php
/var/www/htdocs/bonfire/application/third_party/MX/Config.php
Controller.php
/var/www/htdocs/bonfire/application/third_party/MX/Controller.php
Lang.php
/var/www/htdocs/bonfire/application/third_party/MX/Lang.php
Loader.php
/var/www/htdocs/bonfire/application/third_party/MX/Loader.php
Benchmark.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Benchmark.php
CodeIgniter.php
/var/www/htdocs/bonfire/bonfire/ci3/core/CodeIgniter.php
Common.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Common.php
Config.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Config.php
Controller.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Controller.php
Hooks.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Hooks.php
Input.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Input.php
Lang.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Lang.php
Loader.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Loader.php
Log.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Log.php
Model.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Model.php
Output.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Output.php
Router.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Router.php
Security.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Security.php
URI.php
/var/www/htdocs/bonfire/bonfire/ci3/core/URI.php
Utf8.php
/var/www/htdocs/bonfire/bonfire/ci3/core/Utf8.php
hash.php
/var/www/htdocs/bonfire/bonfire/ci3/core/compat/hash.php
mbstring.php
/var/www/htdocs/bonfire/bonfire/ci3/core/compat/mbstring.php
password.php
/var/www/htdocs/bonfire/bonfire/ci3/core/compat/password.php
standard.php
/var/www/htdocs/bonfire/bonfire/ci3/core/compat/standard.php
DB.php
/var/www/htdocs/bonfire/bonfire/ci3/database/DB.php
DB_driver.php
/var/www/htdocs/bonfire/bonfire/ci3/database/DB_driver.php
DB_query_builder.php
/var/www/htdocs/bonfire/bonfire/ci3/database/DB_query_builder.php
DB_result.php
/var/www/htdocs/bonfire/bonfire/ci3/database/DB_result.php
mysqli_driver.php
/var/www/htdocs/bonfire/bonfire/ci3/database/drivers/mysqli/mysqli_driver.php
mysqli_result.php
/var/www/htdocs/bonfire/bonfire/ci3/database/drivers/mysqli/mysqli_result.php
directory_helper.php
/var/www/htdocs/bonfire/bonfire/ci3/helpers/directory_helper.php
form_helper.php
/var/www/htdocs/bonfire/bonfire/ci3/helpers/form_helper.php
language_helper.php
/var/www/htdocs/bonfire/bonfire/ci3/helpers/language_helper.php
url_helper.php
/var/www/htdocs/bonfire/bonfire/ci3/helpers/url_helper.php
profiler_lang.php
/var/www/htdocs/bonfire/bonfire/ci3/language/english/profiler_lang.php
Cache.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Cache/Cache.php
Cache_dummy.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Cache/drivers/Cache_dummy.php
Driver.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Driver.php
CI_Session_driver_interface.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Session/CI_Session_driver_interface.php
PHP8SessionWrapper.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Session/PHP8SessionWrapper.php
Session.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Session/Session.php
Session_driver.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Session/Session_driver.php
Session_database_driver.php
/var/www/htdocs/bonfire/bonfire/ci3/libraries/Session/drivers/Session_database_driver.php
BF_Loader.php
/var/www/htdocs/bonfire/bonfire/core/BF_Loader.php
BF_Router.php
/var/www/htdocs/bonfire/bonfire/core/BF_Router.php
BF_directory_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/BF_directory_helper.php
BF_form_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/BF_form_helper.php
application_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/application_helper.php
config_file_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/config_file_helper.php
markdown_extended_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/markdown_extended_helper.php
markdown_helper.php
/var/www/htdocs/bonfire/bonfire/helpers/markdown_helper.php
Assets.php
/var/www/htdocs/bonfire/bonfire/libraries/Assets.php
BF_Model.php
/var/www/htdocs/bonfire/bonfire/libraries/BF_Model.php
CommonMark.php
/var/www/htdocs/bonfire/bonfire/libraries/CommonMark.php
CommonMarkDriver.php
/var/www/htdocs/bonfire/bonfire/libraries/CommonMark/CommonMarkDriver.php
CommonMark_MarkdownExtended.php
/var/www/htdocs/bonfire/bonfire/libraries/CommonMark/drivers/CommonMark_MarkdownExtended.php
Console.php
/var/www/htdocs/bonfire/bonfire/libraries/Console.php
Events.php
/var/www/htdocs/bonfire/bonfire/libraries/Events.php
Modules.php
/var/www/htdocs/bonfire/bonfire/libraries/Modules.php
Route.php
/var/www/htdocs/bonfire/bonfire/libraries/Route.php
Template.php
/var/www/htdocs/bonfire/bonfire/libraries/Template.php
docs.php
/var/www/htdocs/bonfire/bonfire/modules/docs/config/docs.php
routes.php
/var/www/htdocs/bonfire/bonfire/modules/docs/config/routes.php
Docs.php
/var/www/htdocs/bonfire/bonfire/modules/docs/controllers/Docs.php
docs_lang.php
/var/www/htdocs/bonfire/bonfire/modules/docs/language/english/docs_lang.php
_sidebar.php
/var/www/htdocs/bonfire/bonfire/modules/docs/views/_sidebar.php
index.php
/var/www/htdocs/bonfire/bonfire/modules/docs/views/index.php
Settings_lib.php
/var/www/htdocs/bonfire/bonfire/modules/settings/libraries/Settings_lib.php
Settings_model.php
/var/www/htdocs/bonfire/bonfire/modules/settings/models/Settings_model.php
index.php
index.php
index.php
themes/docs/index.php