Web Gear is a free, lightweight open source web development platform written in PHP, aimed at developing fast web applications, based on a well defined MVC structure.

Application

Overview

This class represents the main application engine. It handles loading of custom modules and libraries, their initialization, and it defines methods for easy library loading, as well as URL redirection. It is automatically loaded by the bootstrap file (index.php) upon startup.

The Application class is declared final. That means you cannot extend it. Also, all of its methods are static, meaning that you cannot create instances of this class. Its methods are available from within any controller, helper, or template file.

Common methods

string Application::getApplicationName()

Returns the current application name. This is initially set at startup with the value of the APPLICATION_NAME constant, defined in the includes/config/defs.php file.

void Application::setApplicationName(string applicationName)

Sets the application name. Can be called from any place, as the rest of the methods in this class.

Registry Application::getRoutes()

Returns a Registry object containing all routes defined in includes/config/routes.ini.

void Application::run()

First, this method checks that everything is alright with the system configuration, after which proceeds loading libraries, configuring them, parsing the user defined routes, and dispatching the user requested action.

void Application::redirect(string url)

Redirects the user to a given URL. This method will send a HTTP header, therefore cannot be used within template files.

void Application::stop([int error_code = 0])

Stops the application execution, exiting with the given code. An error code of 0 means that the application stopped without errors.