Chapter 3. Core component

Table of Contents

Predefined classes, constants and functions
Classes
Constants
Functions
Interfaces
Autoload
Exceptions
Default exception handling
Safely throwing exceptions
Catching PHP errors
Recommended practices
Server log
Log format
Native language support
Options
Translation files

The core component of the Web:Extend framework represents a set of classes, constants and functions defined upon inclusion of the core file, wee/wee.php. The core of the framework is very minimalist, initializing only what is required by other modules to work correctly.

You can load Web:Extend using the following code:

<?php

define('ALLOW_INCLUSION', 1);
require('wee/wee.php');

The framework version can be obtained through the WEE_VERSION constant.

The format of the version is compatible with PHP's version_compare function. You can determine if the current version of the framework is the one you need by using the following snippet:

<?php

if (version_compare(WEE_VERSION, '0.4.0')) {
	echo 'I am running Web:Extend version 0.4.0.';
}

If magic quotes are enabled, the framework will automatically disable them and remove all the magic quotes from the input data. We recommend however that you disable it directly in the PHP configuration file if possible.

Predefined classes, constants and functions

Constants

Apart from the framework's version, a few other constants are defined. Some can be overridden while others are defined depending on the context.

These constants are defined only if they are not yet defined. This means you can override their default value if you define them before loading the framework.

  • APP_PATH: path to the application's root based on the requested URI

  • ROOT_PATH: path to the application's root in the filesystem (the folder containing the bootstrap file index.php)

  • PHP_EXT: extension for PHP files; defaults to '.php'

  • CLASS_EXT: extension for PHP class files; defaults to '.class' . PHP_EXT

These constants are defined depending on the environment. You cannot override them.

  • WEE_CLI: defined if the script was called from the command line

  • WEE_ON_WINDOWS: defined if the script is running on Windows

Functions

Interfaces

  • Mappable: defines the method toArray returning the array representation of the object

  • Printable: defines the method toString returning the string representation of the object