Fat-Free Framework  3.3.0  Overview Class List Hierarchy
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Base Class Reference

Base structure. More...

+ Inheritance diagram for Base:

Public Member Functions

 sync ($key)
 
 build ($url)
 
 parse ($str)
 
 compile ($str)
 
ref ($key, $add=TRUE)
 
 exists ($key, &$val=NULL)
 
 devoid ($key)
 
 set ($key, $val, $ttl=0)
 
 get ($key, $args=NULL)
 
 clear ($key)
 
 mset (array $vars, $prefix='', $ttl=0)
 
 hive ()
 
 copy ($src, $dst)
 
 concat ($key, $val)
 
 flip ($key)
 
 push ($key, $val)
 
 pop ($key)
 
 unshift ($key, $val)
 
 shift ($key)
 
 merge ($key, $src)
 
 fixslashes ($str)
 
 split ($str)
 
 stringify ($arg, array $stack=NULL)
 
 csv (array $args)
 
 camelcase ($str)
 
 snakecase ($str)
 
 sign ($num)
 
 hash ($str)
 
 base64 ($data, $mime)
 
 encode ($str)
 
 decode ($str)
 
 recursive ($arg, $func, $stack=NULL)
 
 clean ($arg, $tags=NULL)
 
 scrub (&$var, $tags=NULL)
 
 format ()
 
 language ($code)
 
 lexicon ($path)
 
 serialize ($arg)
 
 unserialize ($arg)
 
 status ($code)
 
 expire ($secs=0)
 
 error ($code, $text='', array $trace=NULL)
 
 mock ($pattern, array $args=NULL, array $headers=NULL, $body=NULL)
 
 route ($pattern, $handler, $ttl=0, $kbps=0)
 
 reroute ($url, $permanent=FALSE)
 
 map ($url, $class, $ttl=0, $kbps=0)
 
 redirect ($pattern, $url)
 
 blacklisted ($ip)
 
 run ()
 
 call ($func, $args=NULL, $hooks='')
 
 chain ($funcs, $args=NULL)
 
 relay ($funcs, $args=NULL)
 
 config ($file)
 
 mutex ($id, $func, $args=NULL)
 
 read ($file, $lf=FALSE)
 
 write ($file, $data, $append=FALSE)
 
 highlight ($text)
 
 dump ($expr)
 
 rel ($url)
 
 unload ($cwd)
 
 __construct ()
 Bootstrap.
 

Public Attributes

const GLOBALS ='GET|POST|COOKIE|REQUEST|SESSION|FILES|SERVER|ENV'
 Mapped PHP globals.
 
const VERBS ='GET|HEAD|POST|PUT|PATCH|DELETE|CONNECT'
 HTTP verbs.
 
const MODE =0755
 Default directory permissions.
 
const CSS ='code.css'
 Syntax highlighting stylesheet.
 
 $init
 Initial settings.
 
 $languages
 Language lookup sequence.
 
 $fallback ='en'
 Default fallback language.
 
const PACKAGE ='Fat-Free Framework'
 
const VERSION ='3.3.0-Release'
 
const HTTP_100 ='Continue'
 
const HTTP_101 ='Switching Protocols'
 
const HTTP_200 ='OK'
 
const HTTP_201 ='Created'
 
const HTTP_202 ='Accepted'
 
const HTTP_203 ='Non-Authorative Information'
 
const HTTP_204 ='No Content'
 
const HTTP_205 ='Reset Content'
 
const HTTP_206 ='Partial Content'
 
const HTTP_300 ='Multiple Choices'
 
const HTTP_301 ='Moved Permanently'
 
const HTTP_302 ='Found'
 
const HTTP_303 ='See Other'
 
const HTTP_304 ='Not Modified'
 
const HTTP_305 ='Use Proxy'
 
const HTTP_307 ='Temporary Redirect'
 
const HTTP_400 ='Bad Request'
 
const HTTP_401 ='Unauthorized'
 
const HTTP_402 ='Payment Required'
 
const HTTP_403 ='Forbidden'
 
const HTTP_404 ='Not Found'
 
const HTTP_405 ='Method Not Allowed'
 
const HTTP_406 ='Not Acceptable'
 
const HTTP_407 ='Proxy Authentication Required'
 
const HTTP_408 ='Request Timeout'
 
const HTTP_409 ='Conflict'
 
const HTTP_410 ='Gone'
 
const HTTP_411 ='Length Required'
 
const HTTP_412 ='Precondition Failed'
 
const HTTP_413 ='Request Entity Too Large'
 
const HTTP_414 ='Request-URI Too Long'
 
const HTTP_415 ='Unsupported Media Type'
 
const HTTP_416 ='Requested Range Not Satisfiable'
 
const HTTP_417 ='Expectation Failed'
 
const HTTP_500 ='Internal Server Error'
 
const HTTP_501 ='Not Implemented'
 
const HTTP_502 ='Bad Gateway'
 
const HTTP_503 ='Service Unavailable'
 
const HTTP_504 ='Gateway Timeout'
 
const HTTP_505 ='HTTP Version Not Supported'
 
const REQ_SYNC =1
 
const REQ_AJAX =2
 
const E_Pattern ='Invalid routing pattern: %s'
 
const E_Named ='Named route does not exist: %s'
 
const E_Fatal ='Fatal error: %s'
 
const E_Open ='Unable to open %s'
 
const E_Routes ='No routes specified'
 
const E_Class ='Invalid class %s'
 
const E_Method ='Invalid method %s'
 
const E_Hive ='Invalid hive key %s'
 

Protected Member Functions

 autoload ($class)
 

Additional Inherited Members

- Static Public Member Functions inherited from Prefab
static instance ()
 

Detailed Description

Base structure.

Member Function Documentation

Base::autoload (   $class)
protected

Namespace-aware class autoloader

Returns
mixed
Parameters
$classstring
Base::base64 (   $data,
  $mime 
)

Return Base64-encoded equivalent

Returns
string
Parameters
$datastring
$mimestring
Base::blacklisted (   $ip)

Return TRUE if IPv4 address exists in DNSBL

Returns
bool
Parameters
$ipstring
Base::build (   $url)

Replace tokenized URL with current route's token values

Returns
string
Parameters
$urlarray|string
Base::call (   $func,
  $args = NULL,
  $hooks = '' 
)

Execute callback/hooks (supports 'class->method' format)

Returns
mixed|FALSE
Parameters
$funccallback
$argsmixed
$hooksstring
Base::camelcase (   $str)

Convert snakecase string to camelcase

Returns
string
Parameters
$strstring
Base::chain (   $funcs,
  $args = NULL 
)

Execute specified callbacks in succession; Apply same arguments to all callbacks

Returns
array
Parameters
$funcsarray|string
$argsmixed
Base::clean (   $arg,
  $tags = NULL 
)

Remove HTML tags (except those enumerated) and non-printable characters to mitigate XSS/code injection attacks

Returns
mixed
Parameters
$argmixed
$tagsstring
Base::clear (   $key)

Unset hive key

Returns
NULL
Parameters
$keystring
Base::compile (   $str)

Convert JS-style token to PHP expression

Returns
string
Parameters
$strstring
Base::concat (   $key,
  $val 
)

Concatenate string to hive string variable

Returns
string
Parameters
$keystring
$valstring
Base::config (   $file)

Configure framework according to .ini-style file settings

Returns
NULL
Parameters
$filestring
Base::copy (   $src,
  $dst 
)

Copy contents of hive variable to another

Returns
mixed
Parameters
$srcstring
$dststring
Base::csv ( array  $args)

Flatten array values and return as CSV string

Returns
string
Parameters
$argsarray
Base::decode (   $str)

Convert HTML entities back to characters

Returns
string
Parameters
$strstring
Base::devoid (   $key)

Return TRUE if hive key is empty and not cached

Returns
bool
Parameters
$keystring
Base::dump (   $expr)

Dump expression with syntax highlighting

Returns
NULL
Parameters
$exprmixed
Base::encode (   $str)

Convert special characters to HTML entities

Returns
string
Parameters
$strstring
Base::error (   $code,
  $text = '',
array  $trace = NULL 
)

Log error; Execute ONERROR handler if defined, else display default error page (HTML for synchronous requests, JSON string for AJAX requests)

Returns
NULL
Parameters
$codeint
$textstring
$tracearray
Base::exists (   $key,
$val = NULL 
)

Return TRUE if hive key is set (or return timestamp and TTL if cached)

Returns
bool
Parameters
$keystring
$valmixed
Base::expire (   $secs = 0)

Send cache metadata to HTTP client

Returns
NULL
Parameters
$secsint
Base::fixslashes (   $str)

Convert backslashes to slashes

Returns
string
Parameters
$strstring
Base::flip (   $key)

Swap keys and values of hive array variable

Returns
array
Parameters
$keystring
Base::format ( )

Return locale-aware formatted string

Returns
string
Base::get (   $key,
  $args = NULL 
)

Retrieve contents of hive key

Returns
mixed
Parameters
$keystring
$argsstring|array
Base::hash (   $str)

Generate 64bit/base36 hash

Returns
string
Parameters
$str
Base::highlight (   $text)

Apply syntax highlighting

Returns
string
Parameters
$textstring
Base::hive ( )

Publish hive contents

Returns
array
Base::language (   $code)

Assign/auto-detect language

Returns
string
Parameters
$codestring
Base::lexicon (   $path)

Transfer lexicon entries to hive

Returns
array
Parameters
$pathstring
Base::map (   $url,
  $class,
  $ttl = 0,
  $kbps = 0 
)

Provide ReST interface by mapping HTTP verb to class method

Returns
NULL
Parameters
$urlstring
$classstring
$ttlint
$kbpsint
Base::merge (   $key,
  $src 
)

Merge array with hive array variable

Returns
array
Parameters
$keystring
$srcstring|array
Base::mock (   $pattern,
array  $args = NULL,
array  $headers = NULL,
  $body = NULL 
)

Mock HTTP request

Returns
NULL
Parameters
$patternstring
$argsarray
$headersarray
$bodystring
Base::mset ( array  $vars,
  $prefix = '',
  $ttl = 0 
)

Multi-variable assignment using associative array

Returns
NULL
Parameters
$varsarray
$prefixstring
$ttlint
Base::mutex (   $id,
  $func,
  $args = NULL 
)

Create mutex, invoke callback then drop ownership when done

Returns
mixed
Parameters
$idstring
$funccallback
$argsmixed
Base::parse (   $str)

Parse string containing key-value pairs and use as routing tokens

Returns
NULL
Parameters
$strstring
Base::pop (   $key)

Remove last element of hive array variable

Returns
mixed
Parameters
$keystring
Base::push (   $key,
  $val 
)

Add element to the end of hive array variable

Returns
mixed
Parameters
$keystring
$valmixed
Base::read (   $file,
  $lf = FALSE 
)

Read file (with option to apply Unix LF as standard line ending)

Returns
string
Parameters
$filestring
$lfbool
Base::recursive (   $arg,
  $func,
  $stack = NULL 
)

Invoke callback recursively for all data types

Returns
mixed
Parameters
$argmixed
$funccallback
$stackarray
Base::redirect (   $pattern,
  $url 
)

Redirect a route to another URL

Returns
NULL
Parameters
$patternstring|array
$urlstring
& Base::ref (   $key,
  $add = TRUE 
)

Get hive key reference/contents; Add non-existent hive keys, array elements, and object properties by default

Returns
mixed
Parameters
$keystring
$addbool
Base::rel (   $url)

Return path relative to the base directory

Returns
string
Parameters
$urlstring
Base::relay (   $funcs,
  $args = NULL 
)

Execute specified callbacks in succession; Relay result of previous callback as argument to the next callback

Returns
array
Parameters
$funcsarray|string
$argsmixed
Base::reroute (   $url,
  $permanent = FALSE 
)

Reroute to specified URI

Returns
NULL
Parameters
$urlstring
$permanentbool
Base::route (   $pattern,
  $handler,
  $ttl = 0,
  $kbps = 0 
)

Bind handler to route pattern

Returns
NULL
Parameters
$patternstring|array
$handlercallback
$ttlint
$kbpsint
Base::run ( )

Match routes against incoming URI

Returns
NULL
Base::scrub ( $var,
  $tags = NULL 
)

Similar to clean(), except that variable is passed by reference

Returns
mixed
Parameters
$varmixed
$tagsstring
Base::serialize (   $arg)

Return string representation of PHP value

Returns
string
Parameters
$argmixed
Base::set (   $key,
  $val,
  $ttl = 0 
)

Bind value to hive key

Returns
mixed
Parameters
$keystring
$valmixed
$ttlint
Base::shift (   $key)

Remove first element of hive array variable

Returns
mixed
Parameters
$keystring
Base::sign (   $num)

Return -1 if specified number is negative, 0 if zero, or 1 if the number is positive

Returns
int
Parameters
$nummixed
Base::snakecase (   $str)

Convert camelcase string to snakecase

Returns
string
Parameters
$strstring
Base::split (   $str)

Split comma-, semi-colon, or pipe-separated string

Returns
array
Parameters
$strstring
Base::status (   $code)

Send HTTP/1.1 status header; Return text equivalent of status code

Returns
string
Parameters
$codeint
Base::stringify (   $arg,
array  $stack = NULL 
)

Convert PHP expression/value to compressed exportable string

Returns
string
Parameters
$argmixed
$stackarray
Base::sync (   $key)

Sync PHP global with corresponding hive key

Returns
array
Parameters
$keystring
Base::unload (   $cwd)

Execute framework/application shutdown sequence

Returns
NULL
Parameters
$cwdstring
Base::unserialize (   $arg)

Return PHP value derived from string

Returns
string
Parameters
$argmixed
Base::unshift (   $key,
  $val 
)

Add element to the beginning of hive array variable

Returns
mixed
Parameters
$keystring
$valmixed
Base::write (   $file,
  $data,
  $append = FALSE 
)

Exclusive file write

Returns
int|FALSE
Parameters
$filestring
$datamixed
$appendbool

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