Overview

Packages

  • Pinoco
    • PAL

Classes

  • Pinoco
  • Pinoco_Delegate
  • Pinoco_DynamicVars
  • Pinoco_HttpRequestVars
  • Pinoco_List
  • Pinoco_MIMEType
  • Pinoco_NativeRenderer
  • Pinoco_NothingVars
  • Pinoco_NullRenderer
  • Pinoco_OptionalParam
  • Pinoco_Pagination
  • Pinoco_PDOStatementWrapper
  • Pinoco_PDOWrapper
  • Pinoco_Renderer
  • Pinoco_Router
  • Pinoco_TALRenderer
  • Pinoco_TestEnvironment
  • Pinoco_Validator
  • Pinoco_ValidatorContext
  • Pinoco_Vars

Interfaces

  • Pinoco_ArrayConvertible

Functions

  • __pinoco_autoload_impl
  • Overview
  • Package
  • Class
  • Tree

Class Pinoco

Pinoco web site environment It makes existing static web site dynamic transparently.

Install PHPTAL. Make your application directory anywhere.

Put .htaccess in your site root.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} \.(html|php)$ [OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !_gateway\.php$
RewriteRule ^(.*)$   _gateway.php/$1 [L,QSA]
#...or RewriteRule ^(.*)$   _gateway.php?PATH_INFO=$1 [L,QSA]

Put _gateway.php in your site root.

require_once 'Pinoco.php';
Pinoco::create("*** your_app_dir ***", array(
//    'use_mod_rewrite'  => true,  // true or false default true
//    'use_path_info'    => true,  // true or false default true
//    'custom_path_info' => false, // false(auto) or string default false
//    'directory_index'  => "index.html index.php", // string like DirectoryIndex directive default "index.html index.php"
))->run();

Pinoco::create guesses HTTP request to create Pinoco instance. If this method can't work file in your environment, you can create Pinoco environment manually via "new" operator using your own parameters.

Pinoco_Vars implements IteratorAggregate, ArrayAccess, Countable, Pinoco_ArrayConvertible
Extended by Pinoco_DynamicVars
Extended by Pinoco
Package: Pinoco
Copyright: Copyright 2010-2012, Hisateru Tanaka <tanakahisateru@gmail.com>
License: License (http://www.opensource.org/licenses/mit-license.php)
Author: Hisateru Tanaka <tanakahisateru@gmail.com>
Located at Pinoco.php
Methods summary
public static Pinoco
# create( string $sysdir, array $options = array() )

It provides a suitable Pinoco instance in regular usage.

It provides a suitable Pinoco instance in regular usage.

Parameters

$sysdir
string
$sysdir
$options
array
$options

Returns

Pinoco
public
# __construct( string $baseuri, string $dispatcher, string $path, string $basedir, string $sysdir, boolean $testing = false )

Pinoco constructor.

Pinoco constructor.

Parameters

$baseuri
string
$baseuri
$dispatcher
string
$dispatcher
$path
string
$path
$basedir
string
$basedir
$sysdir
string
$sysdir
$testing
boolean
$testing

Throws

InvalidArgumentException

See

src/Pinoco#create($sysdir, $options)

Overrides

Pinoco_Vars::__construct()
public
# __toString( )

Overrides

Pinoco_Vars::__toString()
public Pinoco
# config( string $name, string|array $source )

Imports named attribute from file or array.

Imports named attribute from file or array.

Parameters

$name
string
$name Attribute name of Pinoco instance.
$source
string|array
$source Config file path based on the app dir or array.

Returns

Pinoco

Throws

InvalidArgumentException
public static Pinoco_Vars
# newVars( mixed $init = array() )

It provides a new Vars object (that can be filled with existing Array).

It provides a new Vars object (that can be filled with existing Array).

Parameters

$init
mixed
$init

Returns

Pinoco_Vars
public static Pinoco_List
# newList( mixed $init = array() )

It provides a new List object (that can be filled with existing Array).

It provides a new List object (that can be filled with existing Array).

Parameters

$init
mixed
$init

Returns

Pinoco_List
public static Pinoco_NothingVars
# newNothing( )

It provides the NothingVars object.

It provides the NothingVars object.

Returns

Pinoco_NothingVars
public static Pinoco_Vars
# wrapVars( array & $ref )

It provides a Vars object as existing Array wrapper.

It provides a Vars object as existing Array wrapper.

Parameters

$ref
array
&$ref

Returns

Pinoco_Vars
public static Pinoco_List
# wrapList( array & $ref )

It provides a List object as existing Array wrapper.

It provides a List object as existing Array wrapper.

Parameters

$ref
array
&$ref

Returns

Pinoco_List
public string
# get_baseuri( )

Web site root URI.

Web site root URI.

Returns

string
public string
# get_basedir( )

Web site root directory in local file system.

Web site root directory in local file system.

Returns

string
public string
# get_sysdir( )

Application directory.

Application directory.

Returns

string
public boolean
# get_testing( )

Test mode flag.

Test mode flag.

Returns

boolean
public Pinoco_List
# get_incdir( )

Include search directories.

Include search directories.

Returns

Pinoco_List
public Pinoco_Vars
# get_request( )

Request related global variables wrapper.

Request related global variables wrapper.

Returns

Pinoco_Vars
public string
# get_path( )

Local resource path under base URI.

Local resource path under base URI.

Returns

string
public string
# get_script( )

Current hook script if it running.

Current hook script if it running.

Returns

string
public Pinoco_List
# get_activity( )

Hook scripts invocation log.

Hook scripts invocation log.

Returns

Pinoco_List
public Pinoco_List
# get_sent_headers( )

Sent headers via Pinoco's method.

Sent headers via Pinoco's method.

Returns

Pinoco_List
public string
# get_subpath( )

Partial path under current script.

Partial path under current script.

Returns

string
public Pinoco_List
# get_pathargs( )

Path elements resolved by _default folders or files.

Path elements resolved by _default folders or files.

Returns

Pinoco_List
public string
# get_directory_index( )

Default files (separated by white space) for directory access.

Default files (separated by white space) for directory access.

Returns

string
public string
# get_page( )

File name to override view.

File name to override view.

Returns

string
public Pinoco_Vars
# get_renderers( )

Page renderers repository. A renderer object is registered to file extension as dictionary key.

Page renderers repository. A renderer object is registered to file extension as dictionary key.

Returns

Pinoco_Vars
public Pinoco_Vars
# get_autolocal( )

Automatically extracted variables for hooks and pages.

Automatically extracted variables for hooks and pages.

Returns

Pinoco_Vars
public callable
# get_url_modifier( )

Special filter for url conversion.

Special filter for url conversion.

Returns

callable
public callable
# get_page_modifier( )

Special filter for default view file.

Special filter for default view file.

Returns

callable
public
# set_incdir( Pinoco_List $dirs )

Include search directories.

Include search directories.

Parameters

$dirs
Pinoco_List
$dirs
public
# set_page( string $page )

File name to override view. Set false if you want an empty output. Set "<default>" if you want to reset to default view.

File name to override view. Set false if you want an empty output. Set "<default>" if you want to reset to default view.

Parameters

$page
string
$page
public
# set_directory_index( string $files )

Default files (separated by white space) for directory access.

Default files (separated by white space) for directory access.

Parameters

$files
string
$files
public
# set_url_modifier( callable $callable )

Special filter for url conversion.

Special filter for url conversion.

Parameters

$callable
callable
$callable
public
# set_page_modifier( callable $callable )

Special filter for default view file.

Special filter for default view file.

Parameters

$callable
callable
$callable
public static
# skip( )

Current hook process will be skipped and invoke the next hook script.

Current hook process will be skipped and invoke the next hook script.

Throws

Pinoco_FlowControlSkip
public static
# terminate( )

Whole hook stage before rendering is terminated and rendering phase is started immediately.

Whole hook stage before rendering is terminated and rendering phase is started immediately.

Throws

Pinoco_FlowControlTerminate
public static
# error( integer $code, string $title = null, string $message = null )

It cancels hooks and rendering and respond HTTP error to browser.

It cancels hooks and rendering and respond HTTP error to browser.

Parameters

$code
integer
$code
$title
string
$title
$message
string
$message

Throws

Pinoco_FlowControlHttpError
public static
# redirect( string $url, boolean $external = false )

Special error to let browser change the location to access.

Special error to let browser change the location to access.

Parameters

$url
string
$url
$external
boolean
$external

Throws

Pinoco_FlowControlHttpRedirect
public static
# notfound( )

Error for Not Found.

Error for Not Found.

Throws

Pinoco_FlowControlHttpError
public static
# forbidden( )

Error for Forbidden.

Error for Forbidden.

Throws

Pinoco_FlowControlHttpError
public
# nocache( )

This method sends headers not to be cached.

This method sends headers not to be cached.

public
# abortIfNotModified( integer $timestamp = null, string $etag = null, integer $lifetime = 86400 )

Conditional flow control. Send cache hints and also might send "304 Not Modified" status if the content has not been changed from previously sent (detected by incoming request header).

Conditional flow control. Send cache hints and also might send "304 Not Modified" status if the content has not been changed from previously sent (detected by incoming request header).

Parameters

$timestamp
integer
$timestamp
$etag
string
$etag
$lifetime
integer
$lifetime
public
# serveStatic( string $filename, integer $lifetime = 86400, string $mime_type = null )

Serves static file or send 304 no-modified response automatically. This method terminates hook script flow.

Serves static file or send 304 no-modified response automatically. This method terminates hook script flow.

Parameters

$filename
string
$filename
$lifetime
integer
$lifetime
$mime_type
string
$mime_type
public
# router( )
public static string
# parentPath( string $path )

Utility to get the parent path.

Utility to get the parent path.

Parameters

$path
string
$path

Returns

string
public string
# resolvePath( string $path, string|boolean $base = false )

It makes relative path absolute.

It makes relative path absolute.

Parameters

$path
string
$path
$base
string|boolean
$base

Returns

string
public boolean
# isRenderablePath( string $path )

Returns if the path can be rendered by registered renderers.

Returns if the path can be rendered by registered renderers.

Parameters

$path
string
$path

Returns

boolean
public boolean
# header( string $string, boolean $replace = true, integer $http_response_code = null )

PHP's header function wrapper.

PHP's header function wrapper.

Parameters

$string
string
$string
$replace
boolean
$replace
$http_response_code
integer
$http_response_code

Returns

boolean
public boolean
# setcookie( string $name, string $value = null, integer $expire = 0, string $path = null, string $domain = null, boolean $secure = false, boolean $httponly = false )

PHP's setcookie function wrapper.

PHP's setcookie function wrapper.

Parameters

$name
string
$name
$value
string
$value
$expire
integer
$expire
$path
string
$path
$domain
string
$domain
$secure
boolean
$secure
$httponly
boolean
$httponly

Returns

boolean
public string
# url( string $path = '', boolean $pure = false )

Returns host based URI from site based or sub-path based relative one.

Returns host based URI from site based or sub-path based relative one.

Parameters

$path
string
$path
$pure
boolean
$pure cancels to call user modifier if true

Returns

string
public
# render( string $page )

Invokes renderer with page file immediately. Default rendering will be canceled. Pass false if you want an empty response.

Invokes renderer with page file immediately. Default rendering will be canceled. Pass false if you want an empty response.

Parameters

$page
string
$page

Throws

InvalidArgumentException
public static string
# mimeType( string $filename )

MIME type of file.

MIME type of file.

Parameters

$filename
string
$filename

Returns

string
public static Pinoco
# instance( )

Returns currently running Pinoco instance.

Returns currently running Pinoco instance.

Returns

Pinoco
public static
# __callStatic( mixed $name, mixed $arguments )
public static
# creditIntoHeader( )

Writes Pinoco credit into HTTP header.

Writes Pinoco credit into HTTP header.

public
# updateIncdir( )

Updates 'include_path' in php.ini by this->incdir.

Updates 'include_path' in php.ini by this->incdir.

public mixed
# subscript( string $script )

Execute an external script in isolated variable scope.

Execute an external script in isolated variable scope.

Parameters

$script
string
$script Script filename absolute path or relative based on current script.

Returns

mixed

Throws

Pinoco_FlowControl
public |string
# run( boolean $output_buffering = true )

Executes all process of Pinoco engine.

Executes all process of Pinoco engine.

Parameters

$output_buffering
boolean
$output_buffering

Returns

|string
public static Pinoco_TestEnvironment
# testenv( string $basedir, string $sysdir, string $baseuri = "/", string $dispatcher = "" )

Provides a testable Pinoco instance for unit test.

Provides a testable Pinoco instance for unit test.

Parameters

$basedir
string
$sysdir
$sysdir
string
$basedir
$baseuri
string
$baseuri
$dispatcher
string
$dispatcher

Returns

Pinoco_TestEnvironment
Methods inherited from Pinoco_DynamicVars
get(), getIterator(), has(), keys(), set()
Methods inherited from Pinoco_Vars
__call(), __get(), __isset(), __set(), __unset(), count(), fromArray(), import(), markAsDirty(), offsetExists(), offsetGet(), offsetSet(), offsetUnset(), registerAsDynamic(), registerAsLazy(), registerAsMethod(), remove(), rget(), setDefault(), setLoose(), toArray(), toArrayRecurse(), values(), wrap()
Constants summary
string VERSION "0.8.0"
#
Magic properties summary
public Pinoco_List $incdir
#

Include pathes

Include pathes

public string $directory_index
#

Space separated directory index files(like Apache)

Space separated directory index files(like Apache)

public string $page
#

Template file to be rendered

Template file to be rendered

public callable $url_modifier
#

URL modification callback

URL modification callback

public callable $page_modifier
#

Template page base path modification callback

Template page base path modification callback

public read-only string $baseuri
#

Base URI

Base URI

public read-only string $basedir
#

Base directory

Base directory

public read-only string $sysdir
#

Application directory

Application directory

public read-only boolean $testing
#

Test mode flag

Test mode flag

public read-only Pinoco_HttpRequestVars $request
#

Request related global variables wrapper

Request related global variables wrapper

public read-only string $path
#

Path under base URI

Path under base URI

public read-only string $script
#

Current hook script

Current hook script

public read-only Pinoco_List $activity
#

Activity history of hook scripts

Activity history of hook scripts

public read-only Pinoco_List $sent_headers
#

Sent headers via Pinoco

Sent headers via Pinoco

public read-only string $subpath
#

Sub-path under current hook script

Sub-path under current hook script

public read-only Pinoco_List $pathargs
#

Path elements matches _default[.*] hooks

Path elements matches _default[.*] hooks

public read-only Pinoco_Vars $renderers
#

File extension to rendering module mappings

File extension to rendering module mappings

public read-only Pinoco_Vars $autolocal
#

Auto extracted variables into local scope

Auto extracted variables into local scope

Pinoco 0.8.0 Documentation API documentation generated by ApiGen 2.8.0