PHP Class Lime\App

Inheritance: implements ArrayAccess
Show file Open project: aheinze/lime Class Usage Examples

Public Properties

Property Type Description
$helpers
$layout
$mimeTypes * mime types
$response Response | null
$statusCodes * status codes
$viewvars * global view variables

Protected Properties

Property Type Description
$apps
$blocks
$events
$exit
$paths
$registry
$routes

Public Methods

Method Description
__construct ( Array $settings = [] ) Constructor
__get ( $name ) accces to services
__invoke ( $helper ) Invoke call
assets ( $src, $version = false )
base ( $path )
baseUrl ( String $path ) : String Returns link based on the base url of the app
bind ( String $path, Closure $callback, boolean $condition = true ) : void Bind request to route
bindClass ( String $class, $alias = false ) : void Bind Class to routes
bindNamespace ( String $namespace, $alias ) : void Bind namespace to routes
block ( String $name, array $options = [] ) : String Get block content
cache ( ) : Mixed Cache helper method
decode ( [type] $data, [type] $pwd ) : [type] Decode RC4 encrypted text
dispatch ( String $path ) : Mixed Dispatch route
encode ( [type] $data, [type] $pwd, boolean $base64encoded = false ) : [type] RC4 encryption
end ( String $name ) : Null End block
escape ( String $string, String $charset = null ) : String Escape string.
get ( String $path, Closure $callback, boolean $condition = true ) : void Bind GET request to route
getClientIp ( ) : String Get client ip.
getClientLang ( $default = "en" ) : String Get client language
getSiteUrl ( $withpath = false ) : String Get site url
hash ( $text, $algo = PASSWORD_BCRYPT ) : String Create Hash
helper ( $helper )
instance ( String $name ) : Object Get App instance
invoke ( String $class, String $action = "index", Array $params = [] ) : Mixed Invoke Class as controller
isAbsolutePath ( $path )
isExit ( ) : boolean Is application stopped?
loadModules ( $dirs, $autoload = true, $prefix = false )
module ( $name )
offsetExists ( $key )
offsetGet ( $key )
offsetSet ( $key, $value ) Array Access implementation
offsetUnset ( $key )
on ( String $event, Closure $callback, integer $priority ) : void Bind an event to closure
param ( String $index = null, Mixed $default = null, Array $source = null ) : Mixed Get request variables
path ( ) : Mixed Path helper method
pathToUrl ( $path ) : boolean | string
post ( String $path, Closure $callback, boolean $condition = true ) : void Bind POST request to route
registerModule ( $name, $dir )
render ( String $____template, Array $_____slots = [] ) : String Render view.
req_is ( String $type ) : boolean Request helper function
reroute ( String $path ) : void Redirect to path.
retrieve ( String $key, Mixed $default = null ) : Mixed Get a value from the Lime registry
route ( )
routeUrl ( String $path ) : String Returns link based on the route url of the app
run ( String $route = null ) : void Run Application
script ( String $src, $version = false ) : String Get script inc. markup
service ( String $name, Closure $callable ) : Object Returns a closure that stores the result of the given closure
set ( String $key, Mixed $value ) Put a value in the Lime registry
start ( String $name ) : Null Start block
stop ( $data = false ) stop application (exit)
style ( String $href, $version = false ) : String Get style inc. markup
trigger ( String $event, Array $params = [] ) : boolean Trigger event.

Protected Methods

Method Description
bootModule ( $module )
render_route ( [type] $route, array $params = [] ) : String Render dispatched route

Method Details

__construct() public method

Constructor
public __construct ( Array $settings = [] )
$settings Array initial registry settings

__get() public method

accces to services
public __get ( $name )

__invoke() public method

Invoke call
public __invoke ( $helper )

assets() public method

public assets ( $src, $version = false )

base() public method

public base ( $path )

baseUrl() public method

Returns link based on the base url of the app
public baseUrl ( String $path ) : String
$path String e.g. /js/myscript.js
return String Link

bind() public method

Bind request to route
public bind ( String $path, Closure $callback, boolean $condition = true ) : void
$path String
$callback Closure
$condition boolean
return void

bindClass() public method

Bind Class to routes
public bindClass ( String $class, $alias = false ) : void
$class String
return void

bindNamespace() public method

Bind namespace to routes
public bindNamespace ( String $namespace, $alias ) : void
$namespace String
return void

block() public method

Get block content
public block ( String $name, array $options = [] ) : String
$name String
$options array
return String

bootModule() protected method

protected bootModule ( $module )

cache() public method

Cache helper method
public cache ( ) : Mixed
return Mixed

decode() public method

Decode RC4 encrypted text
public decode ( [type] $data, [type] $pwd ) : [type]
$data [type]
$pwd [type]
return [type]

dispatch() public method

Dispatch route
public dispatch ( String $path ) : Mixed
$path String
return Mixed

encode() public method

RC4 encryption
public encode ( [type] $data, [type] $pwd, boolean $base64encoded = false ) : [type]
$data [type]
$pwd [type]
$base64encoded boolean [description]
return [type]

end() public method

End block
public end ( String $name ) : Null
$name String
return Null

escape() public method

Escape string.
public escape ( String $string, String $charset = null ) : String
$string String
$charset String
return String

get() public method

Bind GET request to route
public get ( String $path, Closure $callback, boolean $condition = true ) : void
$path String
$callback Closure
$condition boolean
return void

getClientIp() public method

Get client ip.
public getClientIp ( ) : String
return String

getClientLang() public method

Get client language
public getClientLang ( $default = "en" ) : String
return String

getSiteUrl() public method

Get site url
public getSiteUrl ( $withpath = false ) : String
return String

hash() public method

Create Hash
public hash ( $text, $algo = PASSWORD_BCRYPT ) : String
return String

helper() public method

public helper ( $helper )

instance() public static method

Get App instance
public static instance ( String $name ) : Object
$name String Lime app name
return Object Lime app object

invoke() public method

Invoke Class as controller
public invoke ( String $class, String $action = "index", Array $params = [] ) : Mixed
$class String
$action String
$params Array
return Mixed

isAbsolutePath() public method

public isAbsolutePath ( $path )

isExit() public method

Is application stopped?
public isExit ( ) : boolean
return boolean

loadModules() public method

public loadModules ( $dirs, $autoload = true, $prefix = false )

module() public method

public module ( $name )

offsetExists() public method

public offsetExists ( $key )

offsetGet() public method

public offsetGet ( $key )

offsetSet() public method

Array Access implementation
public offsetSet ( $key, $value )

offsetUnset() public method

public offsetUnset ( $key )

on() public method

Bind an event to closure
public on ( String $event, Closure $callback, integer $priority ) : void
$event String
$callback Closure
$priority integer
return void

param() public method

Get request variables
public param ( String $index = null, Mixed $default = null, Array $source = null ) : Mixed
$index String
$default Mixed
$source Array
return Mixed

path() public method

Path helper method
public path ( ) : Mixed
return Mixed

pathToUrl() public method

public pathToUrl ( $path ) : boolean | string
$path
return boolean | string

post() public method

Bind POST request to route
public post ( String $path, Closure $callback, boolean $condition = true ) : void
$path String
$callback Closure
$condition boolean
return void

registerModule() public method

public registerModule ( $name, $dir )

render() public method

Render view.
public render ( String $____template, Array $_____slots = [] ) : String
$____template String Path to view
$_____slots Array Passed variables
return String Rendered view

render_route() protected method

Render dispatched route
protected render_route ( [type] $route, array $params = [] ) : String
$route [type]
$params array
return String

req_is() public method

Request helper function
public req_is ( String $type ) : boolean
$type String
return boolean

reroute() public method

Redirect to path.
public reroute ( String $path ) : void
$path String Path redirect to.
return void

retrieve() public method

Get a value from the Lime registry
public retrieve ( String $key, Mixed $default = null ) : Mixed
$key String
$default Mixed
return Mixed

route() public method

public route ( )

routeUrl() public method

Returns link based on the route url of the app
public routeUrl ( String $path ) : String
$path String e.g. /pages/home
return String Link

run() public method

Run Application
public run ( String $route = null ) : void
$route String Route to parse
return void

script() public method

Get script inc. markup
public script ( String $src, $version = false ) : String
$src String
return String

service() public method

Returns a closure that stores the result of the given closure
public service ( String $name, Closure $callable ) : Object
$name String
$callable Closure
return Object

set() public method

Put a value in the Lime registry
public set ( String $key, Mixed $value )
$key String Key name
$value Mixed Value

start() public method

Start block
public start ( String $name ) : Null
$name String
return Null

stop() public method

stop application (exit)
public stop ( $data = false )

style() public method

Get style inc. markup
public style ( String $href, $version = false ) : String
$href String
return String

trigger() public method

Trigger event.
public trigger ( String $event, Array $params = [] ) : boolean
$event String
$params Array
return boolean

Property Details

$apps protected static property

protected static $apps

$blocks protected property

protected $blocks

$events protected property

protected $events

$exit protected property

protected $exit

$helpers public property

public $helpers

$layout public property

public $layout

$mimeTypes public static property

* mime types
public static $mimeTypes

$paths protected property

protected $paths

$registry protected property

protected $registry

$response public property

public Response,lime|null $response
return Response | null

$routes protected property

protected $routes

$statusCodes public static property

* status codes
public static $statusCodes

$viewvars public property

* global view variables
public $viewvars