/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 68)
ENV_PRODUCTION = 10 (line 67)
E_DEPRECATED = 8192 (line 73)
E_LIM_DEPRECATED = 35000 (line 64)
E_LIM_HTTP = 32768 (line 62)
E_LIM_PHP = 65536 (line 63)
E_USER_DEPRECATED = 16384 (line 74)
HTTP_ACCEPTED = 202 (line 1713)
HTTP_BAD_GATEWAY = 502 (line 1753)
HTTP_BAD_REQUEST = 400 (line 1728)
HTTP_CONFLICT = 409 (line 1737)
HTTP_CONTINUE = 100 (line 1708)
HTTP_CREATED = 201 (line 1712)
HTTP_EXPECTATION_FAILED = 417 (line 1745)
HTTP_FAILED_DEPENDENCY = 424 (line 1748)
HTTP_FORBIDDEN = 403 (line 1731)
HTTP_GATEWAY_TIME_OUT = 504 (line 1755)
HTTP_GONE = 410 (line 1738)
HTTP_INSUFFICIENT_STORAGE = 507 (line 1758)
HTTP_INTERNAL_SERVER_ERROR = 500 (line 1751)
HTTP_LENGTH_REQUIRED = 411 (line 1739)
HTTP_LOCKED = 423 (line 1747)
HTTP_METHOD_NOT_ALLOWED = 405 (line 1733)
HTTP_MOVED_PERMANENTLY = 301 (line 1721)
HTTP_MOVED_TEMPORARILY = 302 (line 1722)
HTTP_MULTIPLE_CHOICES = 300 (line 1720)
HTTP_MULTI_STATUS = 207 (line 1718)
HTTP_NON_AUTHORITATIVE = 203 (line 1714)
HTTP_NOT_ACCEPTABLE = 406 (line 1734)
HTTP_NOT_EXTENDED = 510 (line 1759)
HTTP_NOT_FOUND = 404 (line 1732)
HTTP_NOT_IMPLEMENTED = 501 (line 1752)
HTTP_NOT_MODIFIED = 304 (line 1724)
HTTP_NO_CONTENT = 204 (line 1715)
HTTP_OK = 200 (line 1711)
HTTP_PARTIAL_CONTENT = 206 (line 1717)
HTTP_PAYMENT_REQUIRED = 402 (line 1730)
HTTP_PRECONDITION_FAILED = 412 (line 1740)
HTTP_PROCESSING = 102 (line 1710)
HTTP_PROXY_AUTHENTICATION_REQUIRED = 407 (line 1735)
HTTP_RANGE_NOT_SATISFIABLE = 416 (line 1744)
HTTP_REQUEST_ENTITY_TOO_LARGE = 413 (line 1741)
HTTP_REQUEST_TIME_OUT = 408 (line 1736)
HTTP_REQUEST_URI_TOO_LARGE = 414 (line 1742)
HTTP_RESET_CONTENT = 205 (line 1716)
HTTP_SEE_OTHER = 303 (line 1723)
HTTP_SERVICE_UNAVAILABLE = 503 (line 1754)
HTTP_SWITCHING_PROTOCOLS = 101 (line 1709)
HTTP_TEMPORARY_REDIRECT = 307 (line 1726)
HTTP_UNAUTHORIZED = 401 (line 1729)
HTTP_UNPROCESSABLE_ENTITY = 422 (line 1746)
HTTP_UNSUPPORTED_MEDIA_TYPE = 415 (line 1743)
HTTP_UPGRADE_REQUIRED = 426 (line 1749)
HTTP_USE_PROXY = 305 (line 1725)
HTTP_VARIANT_ALSO_VARIES = 506 (line 1757)
HTTP_VERSION_NOT_SUPPORTED = 505 (line 1756)
LIMONADE = '0.4.4' (line 58)

Limonade version

LIM_SESSION_FLASH_KEY = '_lim_flash_messages' (line 61)
LIM_SESSION_NAME = 'Fresh_and_Minty_Limonade_App' (line 60)
LIM_START_MICROTIME = (float)substr(microtime(),0,10) (line 59)
NOT_FOUND = 404 (line 65)
SERVER_ERROR = 500 (line 66)
X-LIGHTTPD-SEND-FILE = 20 (line 70)
X-SENDFILE = 10 (line 69)
Functions
app_file (line 501)

Returns application root file path

string app_file ()
call_if_exists (line 1641)

Calls a function if exists

mixed call_if_exists (string $func, mixed $arg,..)
  • string $func: the function name
  • mixed $arg,..: (optional)
css (line 1405)

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
define_unless_exists (line 1656)

Define a constant unless it already exists

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

an alias of dispatch_get

void dispatch ( $path_or_array,  $function)
  • $path_or_array
  • $function
dispatch_delete (line 1084)

Add a DELETE route

void dispatch_delete (string $path_or_array, string $function)
  • string $path_or_array
  • string $function
dispatch_get (line 1047)

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

void dispatch_get (string $path_or_array, string $function)
  • string $path_or_array
  • string $function
dispatch_post (line 1060)

Add a POST route

void dispatch_post (string $path_or_array, string $function)
  • string $path_or_array
  • string $function
dispatch_put (line 1072)

Add a PUT route

void dispatch_put (string $path_or_array, string $function)
  • string $path_or_array
  • string $function
env (line 442)

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 531)

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 640)

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 831)

Returns http response status for a given error number

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

Set and returns error output layout

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

Returns notices output rendering and reset notices

string error_notices_render ()
error_type (line 802)

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 2159)

Returns file extension or false if none

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

Checks if $filename is a binary file

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

Checks if $filename is a text file

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

Returns an array of files contained in a directory

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

Detect MIME Content-type for a file

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

Create a file path by concatenation of given arguments

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

Return or output file content

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

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
flash (line 1554)

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 1584)

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 1536)

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 553)

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 1362)

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 1822)

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 1903)

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 1891)

Checks if an HTTP response code is valid

bool http_response_status_is_valid (string $num)
  • string $num
json (line 1434)

Returns json representation of data with proper http headers

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

Set and return current layout

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

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 193)

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 230)

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
redirect (line 1808)

Http redirection

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

Http redirection

void redirect_to ( $params, string $params,...)
  • string $params,...
  • $params
render (line 1302)

Returns a string to output

It might use a a template file or function, 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 1447)

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 920)

Checks if request method is DELETE

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

Checks if request method is GET

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

Checks if request method is HEAD

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

Checks if request method is POST

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

Checks if request method is PUT

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

Returns current request method for a given environment or current one

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

Returns allowed request methods

array request_methods ()
request_method_is_allowed (line 875)

Checks if a request method or current one is allowed

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

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 1693)

Load php files with require_once in a given dir

  • return: paths of loaded files
array require_once_dir (string $path, [string $pattern = "*.php"])
  • string $path: Path in which are the file to load
  • string $pattern: a regexp pattern that filter files to load
run (line 304)

Running application

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

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 293)

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 1767)

Output proper HTTP header for a given HTTP code

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

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 1491)

Returns an url composed of params joined with /

string url_for ([ $params = null], string $params,...)
  • string $params,...
  • $params
v (line 1681)

An alias of value_or_default()

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

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 1390)

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, 17 Oct 2009 18:52:02 +0200 by phpDocumentor 1.4.2