FRED™  3.0
FRED™: Framework for Rapid and Easy Development
Fred Class Reference

Framework for Rapid and Easy Development. More...

Inheritance diagram for Fred:
Thing

Public Member Functions

 __construct ($config)
 Initialize the framework. More...
 
 autoload ($class_name)
 Autoloader. More...
 
 halt ($status=null)
 End the request. More...
 
 externalError ($message, $context=null)
 Handle an (deliberately caused) external error. More...
 
 internalError ($message, $filename=null, $line_no=null, $trace=null)
 Handle an internal error. More...
 
 errorHandler ($error_no, $message, $filename, $line_no)
 Error handler. More...
 
 exceptionHandler ($exception)
 Exception handler. More...
 
 shutdownFunction ()
 Shutdown function. More...
 
 version (&$hash=null)
 Version without hash. More...
 
 replaceVars ($config)
 Replace config keys with variables. More...
 
 dump ()
 Get a dumper. More...
 
 config ($key, $default=null)
 Get a value from the configuration. More...
 
 component ($name)
 Get a component. More...
 
 may ($name)
 Get a component if there is a configuration entry for it. More...
 
 has ($name)
 Get a component if it already exists. More...
 
 clientConfig ()
 Public configuration. More...
 
 __call ($func_name, $params)
 
- Public Member Functions inherited from Thing
 propertyExists ($property)
 Check if a property exists (public or published). More...
 
 constants ($prefix=null)
 Return all constants. More...
 
 get ($key)
 Get one or more properties. More...
 
 set ($key, $value=null)
 Set one or more properties. More...
 
 __get ($key)
 
 __set ($key, $value)
 

Data Fields

const EVENT_HALT = 'fred:halt'
 
const EVENT_EXTERNAL_ERROR = 'fred:externalError'
 
const EVENT_SHUTDOWN = 'fred:shutdown'
 
 $debug = false
 True for debug modus. More...
 
 $autoloadCacheKey = 'fred:autoloadCache'
 Session key for classnames cache. More...
 
 $autoloadMissingKey = 'fred:autoloadMissing'
 Session key for missing classnames cache. More...
 
 $defaultComponentNamespace = __CLASS__
 Default namespace for components. If there is no class name defined for a. More...
 
 $templatePath = __DIR__ . '/../../template/'
 Path for the framework templates. More...
 
 $version = null
 Project version. More...
 
 $ignoreErrors = '/^SOAP-ERROR/'
 Errors to ignore on shutdown (regex). More...
 
 $stripObjectsMemoryLimit = null
 
 $stripObjectsMaxDepth = 10
 
- Data Fields inherited from Thing
const HIDDEN = 0
 Property is hidden. More...
 
const READABLE = 1
 Property is readable. More...
 
const WRITEABLE = 2
 Property is writeable. More...
 
const READWRITE = 3
 Property is readable and writeable. More...
 

Protected Member Functions

 init ()
 Initialize the framework. More...
 
 saveSharedCache ()
 
 stripObjects (&$item, &$objects, $level=0)
 Separate objects. More...
 
 stripTraceObjects (&$trace, &$objects)
 Separate objects from a trace. More...
 
 errorHash ($message, $filename, $line_no)
 
 releaseNotes ()
 Add new release notes to messages and log. More...
 
 maintenance ()
 Check for maintenance. More...
 
 defaultComponentClassName ($name)
 
 setAutoloadNamespaces ($namespaces)
 
 setAutoloadClasses ($classes)
 
 setAutoloadFiles ($classes)
 
 setTimeLimit ($value)
 
 getTimeLimit ()
 
 _get ($key)
 
- Protected Member Functions inherited from Thing
 publish ($property, $visibility=self::READABLE)
 Publish a property (or hide it again). More...
 
 configure ($config)
 Configure the object. More...
 
 _get ($key)
 Default getter if no specific setter is defined, and the property is also not published (readable). More...
 
 _set ($key, $value)
 Default setter if no specific setter is defined, and the property is also not published (writeable). More...
 

Protected Attributes

 $_startTime = null
 Time at which the request started. More...
 
 $_initialized = false
 True if the framework is initialised. More...
 
 $_config = []
 The configuration. More...
 
 $_internalError = false
 True if an internal error has (already) occured. More...
 
 $_errorHash = null
 Hash for the latest caught error. More...
 
 $_errorBacktrace = null
 Backtrace for the latest caught error. More...
 
 $_timeLimit = null
 Execution cut-off timestamp. More...
 
 $_autoloadNamespaces = []
 Autoload namespace prefix (key) en paths (value). More...
 
 $_autoloadClasses = []
 Autoload classes (key) and files (value). More...
 
 $_autoloadFiles = []
 Autoload files (if not covered by the previous options). More...
 
 $_autoloadCache = []
 Register direct location of class files. More...
 
 $_autoloadCacheLimit = 250
 Size limit for the autoload cache. More...
 
 $_autoloadMissing = []
 Register missing autoload classes (prevent double checking). More...
 
 $_sharedCacheFile = null
 Shared cache file. More...
 
 $_sharedCacheTime = null
 Creation time of the shared cache. More...
 
 $_sharedCacheTtl = 600
 Time-to-live for shared cache. More...
 
 $_sharedCacheTtlSpread = 10
 Random spread for TTL. More...
 
 $_components = []
 Initialized components (key = component name, value = component). More...
 
 $_releaseNotesFile = __DIR__ . '/../../doc/pages/notes.php'
 
 $_releaseNotesKey = 'fred:releaseNotesTime'
 Session key for release notes change time. More...
 
 $_maintenanceTime = null
 Date and time set for maintenance (site inaccessible) in 'Y-m-d H:i:s' format. More...
 
 $_maintenanceMessage = []
 Messages to show before maintenance starts. Key = seconds before start to show. More...
 
 $_maintenanceKey = 'fred:maintenanceMessage'
 Session key for last maintenance message. More...
 
- Protected Attributes inherited from Thing
 $_published = []
 Published properties (key = name of property, value = visibility). More...
 

Detailed Description

Framework for Rapid and Easy Development.

The Fred object is at the core of the framework. From this object all components will be initialized. This is done in a 'lazy' manner. That is: only when the component is specificly called (through the component() function or with a magic __get()).

This object also does autoloading and error handling. The magic __call() method is mapped to the item() function of the entity component.

Definition at line 18 of file Fred.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $config)

Initialize the framework.

Parameters
string | array$configThe configuration. In case of a string, the file with this name will be included.

Definition at line 70 of file Fred.php.

Member Function Documentation

◆ __call()

__call (   $func_name,
  $params 
)

Definition at line 523 of file Fred.php.

◆ _get()

_get (   $key)
protected

Definition at line 519 of file Fred.php.

◆ autoload()

autoload (   $class_name)

Autoloader.

The autoloader tries to load a class in 3 steps:

  • If the class is specificly mentioned in the $_autoloadClasses, then the corresponding file will be loaded.
  • If the class name starts with a prefix from the $_autoloadNamespaces, then the rest of the class name (namespace separator = directory separator) and the path corresponding path will be used to create the filename.
  • If both these options fail, all files in the $_autoloadFiles will be loaded (once) (hoping the sought class will be in there).

Definition at line 151 of file Fred.php.

◆ clientConfig()

clientConfig ( )

Public configuration.

Returns
array Public configuration for all components (key = component name, value = public component configuration).

Definition at line 490 of file Fred.php.

◆ component()

component (   $name)

Get a component.

Parameters
string$nameName of the component.
Returns
Fred\Component

Definition at line 455 of file Fred.php.

◆ config()

config (   $key,
  $default = null 
)

Get a value from the configuration.

Parameters
string | array$keyKey to get the value from the configuration (array = nested).
mixed$defaultDefault value if the key does not exist.
Returns
mixed Found value, or default value if the key does not exist.

Definition at line 443 of file Fred.php.

◆ defaultComponentClassName()

defaultComponentClassName (   $name)
protected

Definition at line 447 of file Fred.php.

◆ dump()

dump ( )

Get a dumper.

Returns
\Rsi\Dump

Definition at line 432 of file Fred.php.

◆ errorHandler()

errorHandler (   $error_no,
  $message,
  $filename,
  $line_no 
)

Error handler.

Throws an exception to get a unified error handling. Errors that are suppressed are only logged.

Definition at line 322 of file Fred.php.

◆ errorHash()

errorHash (   $message,
  $filename,
  $line_no 
)
protected

Definition at line 315 of file Fred.php.

◆ exceptionHandler()

exceptionHandler (   $exception)

Exception handler.

Parameters
Exception$exception

Definition at line 334 of file Fred.php.

◆ externalError()

externalError (   $message,
  $context = null 
)

Handle an (deliberately caused) external error.

Definition at line 228 of file Fred.php.

◆ getTimeLimit()

getTimeLimit ( )
protected

Definition at line 514 of file Fred.php.

◆ halt()

halt (   $status = null)

End the request.

Parameters
int | string$statusValue to pass to the exit() function.

Definition at line 179 of file Fred.php.

◆ has()

has (   $name)

Get a component if it already exists.

Parameters
string$nameName of the component.
Returns
Fred\Component False if it did not exist.

Definition at line 483 of file Fred.php.

◆ init()

init ( )
protected

Initialize the framework.

Definition at line 84 of file Fred.php.

◆ internalError()

internalError (   $message,
  $filename = null,
  $line_no = null,
  $trace = null 
)

Handle an internal error.

Parameters
string$messageError message.
string$filenameFile in which the error occured.
int$line_noLine at which the error occured.
array$traceBacktrace of the moment the error occured.

Definition at line 255 of file Fred.php.

◆ maintenance()

maintenance ( )
protected

Check for maintenance.

Definition at line 392 of file Fred.php.

◆ may()

may (   $name)

Get a component if there is a configuration entry for it.

Parameters
string$nameName of the component.
Returns
Fred\Component False if there is no configuration.

Definition at line 473 of file Fred.php.

◆ releaseNotes()

releaseNotes ( )
protected

Add new release notes to messages and log.

Definition at line 366 of file Fred.php.

◆ replaceVars()

replaceVars (   $config)

Replace config keys with variables.

Parameters
mixed$configFor arrays, values with keys starting with a '@' the value is replaced by the variable with that name (and the '@' is removed from the key).
Returns
mixed

Definition at line 418 of file Fred.php.

◆ saveSharedCache()

saveSharedCache ( )
protected

Definition at line 120 of file Fred.php.

◆ setAutoloadClasses()

setAutoloadClasses (   $classes)
protected

Definition at line 501 of file Fred.php.

◆ setAutoloadFiles()

setAutoloadFiles (   $classes)
protected

Definition at line 505 of file Fred.php.

◆ setAutoloadNamespaces()

setAutoloadNamespaces (   $namespaces)
protected

Definition at line 497 of file Fred.php.

◆ setTimeLimit()

setTimeLimit (   $value)
protected

Definition at line 509 of file Fred.php.

◆ shutdownFunction()

shutdownFunction ( )

Shutdown function.

If a (non catched) error is the reason for the shutdown (e.g. a timeout), then the shutdown will be processed as an internal error.

See also
internalError()

Definition at line 347 of file Fred.php.

◆ stripObjects()

stripObjects ( $item,
$objects,
  $level = 0 
)
protected

Separate objects.

Parameters
mixed$itemItem to check on (recursive for arrays).
array$objectsArray to store objects in. Item will be replaced with name of key.
int$levelCurrent nesting level (stops at 10).

Definition at line 188 of file Fred.php.

◆ stripTraceObjects()

stripTraceObjects ( $trace,
$objects 
)
protected

Separate objects from a trace.

Parameters
array$trace
array$objectsArray to store objects in. Item will be replaced with name of key.

Definition at line 217 of file Fred.php.

◆ version()

version ( $hash = null)

Version without hash.

Parameters
string$hashHash from version string.
Returns
string Version number.

Definition at line 359 of file Fred.php.

Field Documentation

◆ $_autoloadCache

$_autoloadCache = []
protected

Register direct location of class files.

Definition at line 47 of file Fred.php.

◆ $_autoloadCacheLimit

$_autoloadCacheLimit = 250
protected

Size limit for the autoload cache.

Definition at line 48 of file Fred.php.

◆ $_autoloadClasses

$_autoloadClasses = []
protected

Autoload classes (key) and files (value).

Definition at line 45 of file Fred.php.

◆ $_autoloadFiles

$_autoloadFiles = []
protected

Autoload files (if not covered by the previous options).

Definition at line 46 of file Fred.php.

◆ $_autoloadMissing

$_autoloadMissing = []
protected

Register missing autoload classes (prevent double checking).

Definition at line 49 of file Fred.php.

◆ $_autoloadNamespaces

$_autoloadNamespaces = []
protected

Autoload namespace prefix (key) en paths (value).

Definition at line 44 of file Fred.php.

◆ $_components

$_components = []
protected

Initialized components (key = component name, value = component).

Definition at line 54 of file Fred.php.

◆ $_config

$_config = []
protected

The configuration.

Definition at line 38 of file Fred.php.

◆ $_errorBacktrace

$_errorBacktrace = null
protected

Backtrace for the latest caught error.

Definition at line 41 of file Fred.php.

◆ $_errorHash

$_errorHash = null
protected

Hash for the latest caught error.

Definition at line 40 of file Fred.php.

◆ $_initialized

$_initialized = false
protected

True if the framework is initialised.

Definition at line 37 of file Fred.php.

◆ $_internalError

$_internalError = false
protected

True if an internal error has (already) occured.

Definition at line 39 of file Fred.php.

◆ $_maintenanceKey

$_maintenanceKey = 'fred:maintenanceMessage'
protected

Session key for last maintenance message.

Definition at line 64 of file Fred.php.

◆ $_maintenanceMessage

$_maintenanceMessage = []
protected

Messages to show before maintenance starts. Key = seconds before start to show.

Definition at line 60 of file Fred.php.

◆ $_maintenanceTime

$_maintenanceTime = null
protected

Date and time set for maintenance (site inaccessible) in 'Y-m-d H:i:s' format.

Definition at line 59 of file Fred.php.

◆ $_releaseNotesFile

$_releaseNotesFile = __DIR__ . '/../../doc/pages/notes.php'
protected

Definition at line 56 of file Fred.php.

◆ $_releaseNotesKey

$_releaseNotesKey = 'fred:releaseNotesTime'
protected

Session key for release notes change time.

Definition at line 57 of file Fred.php.

◆ $_sharedCacheFile

$_sharedCacheFile = null
protected

Shared cache file.

Definition at line 50 of file Fred.php.

◆ $_sharedCacheTime

$_sharedCacheTime = null
protected

Creation time of the shared cache.

Definition at line 51 of file Fred.php.

◆ $_sharedCacheTtl

$_sharedCacheTtl = 600
protected

Time-to-live for shared cache.

Definition at line 52 of file Fred.php.

◆ $_sharedCacheTtlSpread

$_sharedCacheTtlSpread = 10
protected

Random spread for TTL.

Definition at line 53 of file Fred.php.

◆ $_startTime

$_startTime = null
protected

Time at which the request started.

Definition at line 36 of file Fred.php.

◆ $_timeLimit

$_timeLimit = null
protected

Execution cut-off timestamp.

Definition at line 42 of file Fred.php.

◆ $autoloadCacheKey

$autoloadCacheKey = 'fred:autoloadCache'

Session key for classnames cache.

Definition at line 25 of file Fred.php.

◆ $autoloadMissingKey

$autoloadMissingKey = 'fred:autoloadMissing'

Session key for missing classnames cache.

Definition at line 26 of file Fred.php.

◆ $debug

$debug = false

True for debug modus.

Definition at line 24 of file Fred.php.

◆ $defaultComponentNamespace

$defaultComponentNamespace = __CLASS__

Default namespace for components. If there is no class name defined for a.

Definition at line 27 of file Fred.php.

◆ $ignoreErrors

$ignoreErrors = '/^SOAP-ERROR/'

Errors to ignore on shutdown (regex).

Definition at line 32 of file Fred.php.

◆ $stripObjectsMaxDepth

$stripObjectsMaxDepth = 10

Definition at line 34 of file Fred.php.

◆ $stripObjectsMemoryLimit

$stripObjectsMemoryLimit = null

Definition at line 33 of file Fred.php.

◆ $templatePath

$templatePath = __DIR__ . '/../../template/'

Path for the framework templates.

Definition at line 30 of file Fred.php.

◆ $version

$version = null

Project version.

Definition at line 31 of file Fred.php.

◆ EVENT_EXTERNAL_ERROR

const EVENT_EXTERNAL_ERROR = 'fred:externalError'

Definition at line 21 of file Fred.php.

◆ EVENT_HALT

const EVENT_HALT = 'fred:halt'

Definition at line 20 of file Fred.php.

◆ EVENT_SHUTDOWN

const EVENT_SHUTDOWN = 'fred:shutdown'

Definition at line 22 of file Fred.php.


The documentation for this class was generated from the following file: