ipinga

iPinga is the heart of this entire mini-framework.

The logic for developing an application using the iPinga framework goes basically like this…

1) Create an instance of the iPinga class
2) Tell that instance about the routes you want your application to handle
3) Turn iPinga loose to run whichever controller and method you established to handle the incoming request.

Example (sample index.php file)

Sample ./controllers/user.controller.php

Given the above sample files, if the user went to your site at http://example.com, the default controller would be routed to. The resulting output would be:

the-form

If the user then supplied the name “John Magruder” then pressed the submit button, the form would post their data to http://example.com/user/add. The output
would look like this:

user-add

If the user went to the URL of http://example.com/user/get/4, the following would be the output:

anson-jones

Finally, if the user went to the URL of http://example.com/user/list, this would be the output:

user-list

Parent Class

None


Static Methods

\ipinga\ipinga getInstance()
Allows your application to get a reference to the iPinga class
Parameters:
None
Returns:
The iPinga object. An error will be thrown if you have not yet instantiated the iPinga application object
Example:

Public Properties

$routes
This is an array of all the currently defined routes. Under normal circumstances, you really shouldn’t access this directly. Use addRoute() method instead.
Data Type: array of routes
Default Value: Empty array
$defaultRoute
This is a two element array. The first element contains the default controller and the second element contains the method on that controller. Use defaultRoute() instead of accessing this directly, under normal conditions.
Data Type: array
Default Value: Empty array

Public Methods

\ipinga\cargo __construct( [array $overrideConfigOptions] )
This is the class constructor. You can optionally provide an associative array of configuration settings to override the defaults.
Parameters:
$overrideConfigOptions (array: optional) list of configuration settings to override the defaults.
Returns:
A iPinga instance
Example:
void setConfigOptionsToDefault()
Calling this function resets all iPinga internal configuration options to the library defaults
Parameters:
None
Returns:
null
Example:
mixed|void config($array_or_key[, $value = ”])
Getter and setter for application settings
If only one argument is specified and that argument is a string, the value of the setting identified by the first argument will be returned, or NULL if that setting does not exist.

If only one argument is specified and that argument is an associative array, the array will be merged into the existing application settings.

If two arguments are provided, the first argument is the name of the setting to be created or updated, and the second argument is the setting value.
Parameters:
$array_or_key (string or associative array) If a string, the key of the setting to set or retrieve. Else an associated array of setting keys and values
$valueIf $array_or_key is a string, the value of the setting identified by $array_or_key
Returns:
The value of the settings
Example:

\PDO PDO()
Returns a reference to the internal PDO() class object. If the mysql configuration details are incorrect, this function will throw an error.
Parameters:
None
Returns:
A \PDO object
Example:
void run()
Let’s iPinga() take over and invoke the appropriate controller/method to handle the incoming URL request
Parameters:
None
Returns:
null
Example (sample index.php file)
void addRoute($urlToMatch,$controller,$method [,$middleware])
Add a route to controller/method map.
Parameters:
$urlToMatch (string) is the matching information. When an incoming URL request matches, the associated controller/method is fired. Expected parameters should be listed in the matching string as starting with a dollar sign.
$controller (string) name of the controller to invoke if this URL matches the supplied $urlToMatch matching information
$method (string) name of the method on the controller to invoke if this URL matches the supplied $urlToMatch matching information
$middleware (string: optional) is a pipe separated list of middlewares to invoke prior to invoking the controller/method.
Returns:
null
Example (sample index.php file)
void defaultRoute($controller,$method)
Add a default route. This controller/method pair will be invoked if all other routes fail to match or if middleware restricts them from being fired.
Parameters:
$controller (string) name of the controller to invoke
$method (string) name of the method on the controller to invoke
Returns:
null
Example (sample index.php file)