Agile Toolkit  4.2
Agile Toolkit is a powerful web development framework. Inspired by GUI Applications development
ApiCLI Class Reference
Inheritance diagram for ApiCLI:
AbstractView AbstractObject ApiWeb ApiFrontend

Public Member Functions

 __construct ($realm=null)
 addGlobalMethod ($name, $callable)
 hasGlobalMethod ($name)
 removeGlobalMethod ($name)
 _ ($str)
 locate ($type, $filename='', $return='relative')
 locateURL ($type, $filename='')
 locatePath ($type, $filename='')
 addLocation ($location, $contents)
 getBaseURL ()
 url ($page=null, $arguments=array())
 getDestinationURL ($page=null, $arguments=array())
 getLogger ($class_name='Logger')
 caughtException ($e)
 outputFatal ($msg, $shift)
 outputWarning ($msg, $shift=0)
 outputDebug ($msg, $shift=0)
 outputInfo ($msg, $shift=0)
 upCall ($type, $args=array())
 configExceptionOrDefault ($default, $exceptiontext)
 readConfig ($file='config.php')
 setConfig ($config=array())
 getConfig ($path, $default_value=undefined)
 getVersion ($of='atk')
 requires ($addon='atk', $v, $return_only=false)
 versionRequirement ($v, $return_only=false)
 dbConnect ($dsn=null)
 tryConnect ($dsn)

Data Fields

 $db = null
 $logger = null
 $pathfinder = null
 $atk_version = 4.2

Protected Attributes

 $config = null
 $pathfinder_class = 'PathFinder'

Detailed Description

Base class for Command-Line Applications. If you need to share code between multiple APIs, create a controller.

More Info

Constructor & Destructor Documentation

__construct ( realm = null)

Initializes properties of the application. Redefine init() instead of this

Member Function Documentation

_ ( str)

Redefine this function to introduce your localization. Agile Toolkit will pass all system strings through this method. If some methods are not properly passed through, please fork Agile Toolkit in , modify, commit, push your fix and notify authors of Agile Toolkit using contact form on


addGlobalMethod ( name,

Register method with all objects in Agile Toolkit.

See also:
addLocation ( location,

Add new location with additional resources

caughtException ( e)

Is executed if exception is raised during execution. Re-define to have custom handling of exceptions system-wide

Reimplemented in ApiWeb.

configExceptionOrDefault ( default,

Executed when trying to access config parameter which is not find in the file

dbConnect ( dsn = null)

Use database configuration settings from config file to establish default connection

Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();

See also:
getConfig ( path,
default_value = undefined 

Load config if necessary and look up corresponding setting

For given path such as 'dsn' or 'logger/log_dir' returns corresponding config value. Throws ExceptionNotConfigured if not set.

To find out if config is set, do this:

$var_is_set=true; try { $api->getConfig($path); } catch ExceptionNotConfigured($e) { $var_is_set=false; };

getDestinationURL ( page = null,
arguments = array() 

use url()

getLogger ( class_name = 'Logger')

Initialize logger or return existing one

getVersion ( of = 'atk')
hasGlobalMethod ( name)

Returns if a global method with such name was defined

locate ( type,
filename = '',
return = 'relative' 

Find relative path to the resource respective to the current directory.

locatePath ( type,
filename = '' 

Return full system path to specified resource

locateURL ( type,
filename = '' 

Calculate URL pointing to specified resource

outputDebug ( msg,
shift = 0 

Reimplemented in ApiWeb.

outputFatal ( msg,
outputInfo ( msg,
shift = 0 

Reimplemented in ApiWeb.

outputWarning ( msg,
shift = 0 

Reimplemented in ApiWeb.

readConfig ( file = 'config.php')

Read config file and store it in $this->config. Use getConfig() to access

removeGlobalMethod ( name)

Removes global method

requires ( addon = 'atk',
return_only = false 

Verifies version. Should be used by addons. For speed improvement, redefine this into empty function

setConfig ( config = array())

Manually set configuration option

tryConnect ( dsn)

Attempts to connect, but does not raise exception on failure.

upCall ( type,
args = array() 

Uncaught call default handler.

In your application you should handle your own calls. If you do not, the call will be forwarded to API and finaly this method will be executed displaying error message about uncaught call

Reimplemented from AbstractObject.

url ( page = null,
arguments = array() 

Generates URL for specified page. Useful for building links on pages or emails. Returns URL object.

versionRequirement ( v,
return_only = false 


Field Documentation

$atk_version = 4.2

For fast compatibility checks. To be more specific use $api->requires()

$config = null [protected]

Configuration loaded from config.php and config-defaults.php files. Use getConfig() to access

$db = null

Default database connection.

See also:
$logger = null

Points to the instance of system logger (lib/Logger.php) for enriching error logging

$pathfinder = null

Points to the instance of PathFinder class, which is used to locate resource files. PathFinder is the first class to be initialized after API.

$pathfinder_class = 'PathFinder' [protected]

$pr points to profiler. All lines referencing $pr myst be prefixed with the 4-symbol sequence "/ ** /" (no spaces). When deploying to production, you can remove all lines from all files starting with the sequence without affecting how your application works, but slightly improving performance


Skin for web application templates

The documentation for this class was generated from the following file:
 All Data Structures Files Functions Variables Enumerations