/limonade.php

Description

L I M O N A D E

a PHP micro framework.

For more informations: http://github/sofadesign/limonade

Constants
ENV_DEVELOPMENT = 100 (line 70)
ENV_PRODUCTION = 10 (line 69)
E_DEPRECATED = 8192 (line 75)
E_LIM_DEPRECATED = 35000 (line 66)
E_LIM_HTTP = 32768 (line 64)
E_LIM_PHP = 65536 (line 65)
E_USER_DEPRECATED = 16384 (line 76)
HTTP_ACCEPTED = 202 (line 1947)
HTTP_BAD_GATEWAY = 502 (line 1987)
HTTP_BAD_REQUEST = 400 (line 1962)
HTTP_CONFLICT = 409 (line 1971)
HTTP_CONTINUE = 100 (line 1942)
HTTP_CREATED = 201 (line 1946)
HTTP_EXPECTATION_FAILED = 417 (line 1979)
HTTP_FAILED_DEPENDENCY = 424 (line 1982)
HTTP_FORBIDDEN = 403 (line 1965)
HTTP_GATEWAY_TIME_OUT = 504 (line 1989)
HTTP_GONE = 410 (line 1972)
HTTP_INSUFFICIENT_STORAGE = 507 (line 1992)
HTTP_INTERNAL_SERVER_ERROR = 500 (line 1985)
HTTP_LENGTH_REQUIRED = 411 (line 1973)
HTTP_LOCKED = 423 (line 1981)
HTTP_METHOD_NOT_ALLOWED = 405 (line 1967)
HTTP_MOVED_PERMANENTLY = 301 (line 1955)
HTTP_MOVED_TEMPORARILY = 302 (line 1956)
HTTP_MULTIPLE_CHOICES = 300 (line 1954)
HTTP_MULTI_STATUS = 207 (line 1952)
HTTP_NON_AUTHORITATIVE = 203 (line 1948)
HTTP_NOT_ACCEPTABLE = 406 (line 1968)
HTTP_NOT_EXTENDED = 510 (line 1993)
HTTP_NOT_FOUND = 404 (line 1966)
HTTP_NOT_IMPLEMENTED = 501 (line 1986)
HTTP_NOT_MODIFIED = 304 (line 1958)
HTTP_NO_CONTENT = 204 (line 1949)
HTTP_OK = 200 (line 1945)
HTTP_PARTIAL_CONTENT = 206 (line 1951)
HTTP_PAYMENT_REQUIRED = 402 (line 1964)
HTTP_PRECONDITION_FAILED = 412 (line 1974)
HTTP_PROCESSING = 102 (line 1944)
HTTP_PROXY_AUTHENTICATION_REQUIRED = 407 (line 1969)
HTTP_RANGE_NOT_SATISFIABLE = 416 (line 1978)
HTTP_REQUEST_ENTITY_TOO_LARGE = 413 (line 1975)
HTTP_REQUEST_TIME_OUT = 408 (line 1970)
HTTP_REQUEST_URI_TOO_LARGE = 414 (line 1976)
HTTP_RESET_CONTENT = 205 (line 1950)
HTTP_SEE_OTHER = 303 (line 1957)
HTTP_SERVICE_UNAVAILABLE = 503 (line 1988)
HTTP_SWITCHING_PROTOCOLS = 101 (line 1943)
HTTP_TEMPORARY_REDIRECT = 307 (line 1960)
HTTP_UNAUTHORIZED = 401 (line 1963)
HTTP_UNPROCESSABLE_ENTITY = 422 (line 1980)
HTTP_UNSUPPORTED_MEDIA_TYPE = 415 (line 1977)
HTTP_UPGRADE_REQUIRED = 426 (line 1983)
HTTP_USE_PROXY = 305 (line 1959)
HTTP_VARIANT_ALSO_VARIES = 506 (line 1991)
HTTP_VERSION_NOT_SUPPORTED = 505 (line 1990)
LIMONADE = '0.5.0' (line 58)

Limonade version

LIM_NAME = 'Un grand cru qui sait se faire attendre' (line 59)
LIM_SESSION_FLASH_KEY = '_lim_flash_messages' (line 62)
LIM_SESSION_NAME = 'LIMONADE'.str_replace('.','x',LIMONADE) (line 61)
LIM_START_MEMORY = memory_get_usage() (line 63)
LIM_START_MICROTIME = (float)substr(microtime(),0,10) (line 60)
NOT_FOUND = 404 (line 67)
SERVER_ERROR = 500 (line 68)
X-LIGHTTPD-SEND-FILE = 20 (line 72)
X-SENDFILE = 10 (line 71)
Functions
app_file (line 532)

Returns application root file path

string app_file ()
array_replace (line 2541)

For PHP 5 < 5.3.0 (backward compatibility) (from this php doc. note)

$array array_replace ( &$array,  &$array1, string $array, string $array1)
  • string $array
  • string $array1
  • array &$array
  • array &$array1
benchmark (line 1800)

Shows current memory and execution time of the application.

void benchmark ()
call_if_exists (line 1835)

Calls a function if exists

mixed call_if_exists (callback $callback, mixed $arg,..)
  • callback $callback: a function stored in a string variable, or an object and the name of a method within the object See php documentation to learn more about callbacks.
  • mixed $arg,..: (optional)
content_for (line 1765)

Starts capturing block of text

Calling without params stops capturing (same as end_content_for()). After capturing the captured block is put into a variable named $name for later use in layouts. If second parameter is supplied, its content will be used instead of capturing a block of text.

void content_for ([string $name = null], [string $content = null])
  • string $name
  • string $content
css (line 1498)

Returns css output with proper http headers

string css (string $content_or_func, [string $layout = ''], [string $locals = array()])
  • string $content_or_func
  • string $layout
  • string $locals
debug (line 1906)

Dumps a variable into inspectable format

  • return: the variable with output
string debug (anything $var, [bool $output_as_html = true])
  • anything $var: the variable to debug
  • bool $output_as_html: sets whether to wrap output in
define_unless_exists (line 1850)

Define a constant unless it already exists

void define_unless_exists (string $name, string $value)
  • string $name
  • string $value
dispatch (line 1091)

An alias of dispatch_get()

void dispatch ( $path_or_array,  $callback, [ $options = array()])
  • $path_or_array
  • $callback
  • $options
dispatch_delete (line 1144)

Add a DELETE route

void dispatch_delete (string $path_or_array, string $callback, [array $options = array()])
  • string $path_or_array
  • string $callback
  • array $options: (optional). See route() for available options.
dispatch_get (line 1104)

Add a GET route. Also automatically defines a HEAD route.

void dispatch_get (string $path_or_array, string $callback, [array $options = array()])
  • string $path_or_array
  • string $callback
  • array $options: (optional). See route() for available options.
dispatch_post (line 1118)

Add a POST route

void dispatch_post (string $path_or_array, string $callback, [array $options = array()])
  • string $path_or_array
  • string $callback
  • array $options: (optional). See route() for available options.
dispatch_put (line 1131)

Add a PUT route

void dispatch_put (string $path_or_array, string $callback, [array $options = array()])
  • string $path_or_array
  • string $callback
  • array $options: (optional). See route() for available options.
end_content_for (line 1789)

Stops capturing block of text

void end_content_for ()
env (line 473)

Returns limonade environment variables:

'SERVER', 'FILES', 'REQUEST', 'SESSION', 'ENV', 'COOKIE', 'GET', 'POST', 'PUT', 'DELETE'

If a null argument is passed, reset and rebuild environment

array env ([null $reset = null])
  • null $reset: @reset reset and rebuild environment
error (line 563)

Associate a function with error code(s) and return all associations

array error ([string $errno = null], [string $function = null])
  • string $errno
  • string $function
error_default_handler (line 676)

Default error handler

  • return: error output
string error_default_handler (string $errno, string $errstr, string $errfile, string $errline)
  • string $errno
  • string $errstr
  • string $errfile
  • string $errline
error_http_status (line 867)

Returns http response status for a given error number

int error_http_status (string $errno)
  • string $errno
error_layout (line 760)

Set and returns error output layout

string error_layout ([string $layout = false])
  • string $layout
error_notices_render (line 794)

Returns notices output rendering and reset notices

string error_notices_render ()
error_type (line 838)

return error code name for a given code num, or return all errors names

mixed error_type ([string $num = null])
  • string $num
file_extension (line 2463)

Returns file extension or false if none

  • return: false
string, file_extension (string $filename)
  • string $filename
file_is_binary (line 2488)

Checks if $filename is a binary file

void file_is_binary (string $filename)
  • string $filename
file_is_text (line 2476)

Checks if $filename is a text file

bool file_is_text (string $filename)
  • string $filename
file_list_dir (line 2514)

Returns an array of files contained in a directory

array file_list_dir (string $dir)
  • string $dir
file_mime_content_type (line 2384)

Detect MIME Content-type for a file

string file_mime_content_type (string $filename)
  • string $filename: Path to the tested file.
file_path (line 2444)

Create a file path by concatenation of given arguments.

Windows paths with backslash directory separators are normalized in *nix paths.

  • return: normalized path
string file_path ( $path, string $path,)
  • string $path,: ...
  • $path
file_read (line 2501)

Return or output file content

  • return: int
string, file_read ( $filename, [ $return = false])
  • $filename
  • $return
file_read_chunked (line 2413)

Read and output file content and return filesize in bytes or status after closing file.

This function is very efficient for outputing large files without timeout nor too expensive memory use

  • return: int
bool, file_read_chunked (string $filename, [string $retbytes = true])
  • string $filename
  • string $retbytes
filter_var_url (line 2575)

Check if a string is an url

This implementation no longer requires the filter extenstion, so it will improve compatibility with older PHP versions.

  • return: str the string if true, false instead
false, filter_var_url (string $str)
  • string $str
flash (line 1682)

Set and returns flash messages that will be available in the next action via the flash_now() function or the view variable

  1. $flash
.

If multiple values are provided, set

  1. $name
variable with an array of those values. If there is only one value, set
  1. $name
variable with the provided $values or if it's
  1. $name
is an array, merge it with current messages.

  • return: variable value for $name if $name argument is provided, else return all variables
mixed flash ([string, $name = null], [ $value = null], mixed $values,...)
  • mixed $values,...
  • string, $name: array $name
  • $value
flash_now (line 1713)

Set and returns flash messages available for the current action, included those defined in the previous action with flash() Those messages will also be passed to the views and made available in the

  1. $flash
variable.

If multiple values are provided, set

  1. $name
variable with an array of those values. If there is only one value, set
  1. $name
variable with the provided $values or if it's
  1. $name
is an array, merge it with current messages.

  • return: variable value for $name if $name argument is provided, else return all variables
mixed flash_now ([string, $name = null], [ $value = null], mixed $values,...)
  • mixed $values,...
  • string, $name: array $name
  • $value
h (line 1664)

An alias of http://www.php.net/htmlspecialchars.

If no $charset is provided, uses option('encoding') value

void h (string $str, [string $quote_style = ENT_NOQUOTES], [string $charset = null])
  • string $str
  • string $quote_style
  • string $charset
halt (line 585)

Raise an error, passing a given error number and an optional message, then exit.

Error number should be a HTTP status code or a php user error (E_USER...) $errno and $msg arguments can be passsed in any order If no arguments are passed, default $errno is SERVER_ERROR (500)

void halt ([int,string $errno = SERVER_ERROR], [string,string $msg = ''], [mixed $debug_args = null])
  • int,string $errno: Error number or message string
  • string,string $msg: Message string or error number
  • mixed $debug_args: extra data provided for debugging
html (line 1455)

Returns html output with proper http headers

string html (string $content_or_func, [string $layout = ''], [string $locals = array()])
  • string $content_or_func
  • string $layout
  • string $locals
http_response_status (line 2080)

Returns HTTP response status for a given code.

If no code provided, return an array of all status

string,array http_response_status ([string $num = null])
  • string $num
http_response_status_code (line 2161)

Returns an HTTP response status string for a given code

string http_response_status_code (string $num)
  • string $num
http_response_status_is_valid (line 2149)

Checks if an HTTP response code is valid

bool http_response_status_is_valid (string $num)
  • string $num
http_ua_accepts (line 2179)

Check if the _Accept_ header is present, and includes the given `type`.

When the _Accept_ header is not present `true` is returned. Otherwise the given `type` is matched by an exact match, and then subtypes. You may pass the subtype such as "html" which is then converted internally to "text/html" using the mime lookup table.

bool http_ua_accepts (string $type, [string $env = null])
  • string $type
  • string $env
js (line 1513)

Returns javacript output with proper http headers

string js (string $content_or_func, [string $layout = ''], [string $locals = array()])
  • string $content_or_func
  • string $layout
  • string $locals
json (line 1542)

Returns json representation of data with proper http headers

string json (string $data, [int $json_option = 0])
  • string $data
  • int $json_option
layout (line 1468)

Set and return current layout

string layout ([string $function_or_file = null])
  • string $function_or_file
mime_type (line 2213)

Returns mime type for a given extension or if no extension is provided, all mime types in an associative array, with extensions as keys.

(extracted from Orbit source http://orbit.luaforge.net/)

  • return: array
string, mime_type ([string $ext = null])
  • string $ext
option (line 203)

Set and returns options values

If multiple values are provided, set $name option with an array of those values. If there is only one value, set $name option with the provided $values

  • return: option value for $name if $name argument is provided, else return all options
mixed option ([string $name = null], [ $values = null], mixed $values,...)
  • string $name
  • mixed $values,...
  • $values
params (line 240)

Set and returns params

Depending on provided arguments:

* Reset params if first argument is null

* If first argument is an array, merge it with current params

* If there is a second argument $value, set param $name (first argument) with $value

  1.   params('name''Doe'// set 'name' => 'Doe'
* If there is more than 2 arguments, set param $name (first argument) value with an array of next arguments
  1.   params('months''jan''feb''mar'// set 'month' => array('months', 'jan', 'feb', 'mar')

  • return: all params, or one if a first argument $name is provided
mixed params ([mixed $name_or_array_or_null = null], [ $value = null], mixed $value,...)
  • mixed $name_or_array_or_null: could be null || array of params || name of a param (optional)
  • mixed $value,...: for the $name param (optional)
  • $value
partial (line 1442)

Returns a string to output

Shortcut to render with no layout.

string partial (string $content_or_func, [string $locals = array()])
  • string $content_or_func
  • string $locals
redirect (line 2066)

Http redirection

  • deprecated: deprecated since version 0.4. Please use redirect_to() instead.
void redirect ( $uri, string $url)
  • string $url
  • $uri
redirect_to (line 2025)

Http redirection

Same use as url_for() By default HTTP status code is 302, but a different code can be specified with a status key in array parameter.

  1.  redirecto('new','url')# 302 HTTP_MOVED_TEMPORARILY by default
  2.  redirecto('new','url'array('status' => HTTP_MOVED_PERMANENTLY));

void redirect_to (string $params)
  • string $params: or array $param1, $param2...
render (line 1377)

Returns a string to output

It might use a template file, a function, or a formatted string (like http://www.php.net/sprintf). It could be embraced by a layout or not. Local vars can be passed in addition to variables made available with the set() function.

string render (string $content_or_func, [string $layout = ''], [string $locals = array()])
  • string $content_or_func
  • string $layout
  • string $locals
render_file (line 1555)

undocumented function

  • return: number of bytes delivered or file output if $return = true
mixed render_file (string $filename, [string $return = false])
  • string $filename
  • string $return
request_is_delete (line 953)

Checks if request method is DELETE

bool request_is_delete ([string $env = null])
  • string $env
request_is_get (line 920)

Checks if request method is GET

bool request_is_get ([string $env = null])
  • string $env
request_is_head (line 964)

Checks if request method is HEAD

bool request_is_head ([string $env = null])
  • string $env
request_is_post (line 931)

Checks if request method is POST

bool request_is_post ([string $env = null])
  • string $env
request_is_put (line 942)

Checks if request method is PUT

bool request_is_put ([string $env = null])
  • string $env
request_method (line 888)

Returns current request method for a given environment or current one

string request_method ([string $env = null])
  • string $env
request_methods (line 974)

Returns allowed request methods

array request_methods ()
request_method_is_allowed (line 908)

Checks if a request method or current one is allowed

bool request_method_is_allowed ([string $m = null])
  • string $m
request_uri (line 986)

Returns current request uri (the path that will be compared with routes)

(Inspired from codeigniter URI::_fetch_uri_string method)

string request_uri ([ $env = null])
  • $env
require_once_dir (line 1888)

Load php files with require_once in a given dir

  • return: paths of loaded files
array require_once_dir (string $path, [string $pattern = &quot;*.php&quot;], [bool $prevents_output = true])
  • string $path: Path in which are the file to load
  • string $pattern: a regexp pattern that filter files to load
  • bool $prevents_output: security option that prevents output
run (line 314)

Running application

void run ([string $env = null])
  • string $env
set (line 281)

Set and returns template variables

If multiple values are provided, set $name variable with an array of those values. If there is only one value, set $name variable with the provided $values

  • return: variable value for $name if $name argument is provided, else return all variables
mixed set ([string $name = null], [ $values = null], mixed $values,...)
  • string $name
  • mixed $values,...
  • $values
set_or_default (line 303)

Sets a template variable with a value or a default value if value is empty

  • return: setted value
mixed set_or_default (string $name, string $value, string $default)
  • string $name
  • string $value
  • string $default
status (line 2001)

Output proper HTTP header for a given HTTP code

void status ([string $code = 500])
  • string $code
txt (line 1528)

Returns txt output with proper http headers

string txt (string $content_or_func, [string $layout = ''], [string $locals = array()])
  • string $content_or_func
  • string $layout
  • string $locals
url_for (line 1603)

Returns an url composed of params joined with / A param can be a string or an array.

If param is an array, its members will be added at the end of the return url as GET parameters "&key=value".

string url_for ([string $params = null])
  • string $params: or array $param1, $param2 ...
v (line 1875)

An alias of value_or_default()

mixed v (mixed $value, mixed $default)
  • mixed $value
  • mixed $default
value_or_default (line 1862)

Return a default value if provided value is empty

mixed value_or_default (mixed $value, mixed $default)
  • mixed $value
  • mixed $default: default value returned if $value is empty
xml (line 1483)

Returns xml output with proper http headers

string xml ( $data, string $content_or_func, string $layout, string $locals)
  • string $content_or_func
  • string $layout
  • string $locals
  • $data

Documentation generated on Sat, 16 Oct 2010 19:09:43 +0200 by phpDocumentor 1.4.3