PHP Class Whippet

Mostrar archivo Open project: dxw/whippet-server Class Usage Examples

Public Properties

Property Type Description
$cb_cache * Used to manage a cache of hook callbacks
$done_shutdown_function * Flag used to ensure that only one shutdown function gets set
$options * Stores options passed to the routing script
$request_path Note: For a request for a real resource (like a css file) it should be a path to an existing file. For a request for a WordPress page, it will not be.
$request_type * The type of request we're serving
$request_uri * Stores the normalised version of the requested URI's path component.
$start_time * The time this request started being processed

Public Methods

Method Description
__construct ( )
emit_php_error ( $number, $error, $file, $line, $options = ['show-errors' => E_ALL] ) This function actually emits handled PHP errors. It's here instead of in handle_php_error because we want a static version to be used from the bootstrap script.
file_is_in_core ( $file, $options )
get_options ( ) : Array Parse options that are passed to us from stdin.Not sure what the format should be yet. To start with, we probably need options to specify the location of the wordpress installation to run.
handle_php_error ( $number, $error, $file, $line, $context ) Called by the PHP core when an error occurs
message ( $string ) Emits a message to STDOUT, prepended with the current time.
print_r ( $variable ) Dumps an object to STDOUT, using print_r
register_shutdown_function ( )
request_message ( ) Prints basic information about the request being processed
run ( ) Called when the command is run. Sets up the options and environment and then passes off to a more specific handler
serve_file ( ) Serves a static file from the disk
serve_headers ( ) The built-in webserver only emits a minimal set of headers, so add in the usual ones.
serve_script ( ) Serves a specific script; for example, /wp-admin/install.php
serve_wordpress ( ) Serves a wordpress permalink
startswith ( $haystack, $needle )
wps_filter_all ( $hook ) Emits the details of hooks and filters as they are called, if required
wps_filter_parse_query ( $query ) Emits page parameters
wps_filter_query ( $query ) Emits all queries to the console
wps_filter_shutdown ( ) Runs right at the end of execution
wps_filter_template_include ( $template ) Emits template loads to the console

Method Details

__construct() public method

public __construct ( )

emit_php_error() public static method

This function actually emits handled PHP errors. It's here instead of in handle_php_error because we want a static version to be used from the bootstrap script.
public static emit_php_error ( $number, $error, $file, $line, $options = ['show-errors' => E_ALL] )

file_is_in_core() public static method

public static file_is_in_core ( $file, $options )

get_options() public method

Eventually it would be nice to be able to start a development version of wordpress using sqlite (with minimal setup) and just a wp-content folder, with the core being loaded from /usr/share (or similar)
public get_options ( ) : Array
return Array An array of options (probably)

handle_php_error() public method

Called by the PHP core when an error occurs
public handle_php_error ( $number, $error, $file, $line, $context )

message() public static method

Note: if the first character of the string is a newline, that newline will be emitted before the time. Note: this method appends a newline to the string.
public static message ( $string )

print_r() public static method

Dumps an object to STDOUT, using print_r
public static print_r ( $variable )

register_shutdown_function() public method

request_message() public method

Prints basic information about the request being processed
public request_message ( )

run() public method

Called when the command is run. Sets up the options and environment and then passes off to a more specific handler
public run ( )

serve_file() public method

Serves a static file from the disk
public serve_file ( )

serve_headers() public method

Note: this function will not serve content-type or content-length headers.
public serve_headers ( )

serve_script() public method

Serves a specific script; for example, /wp-admin/install.php
public serve_script ( )

serve_wordpress() public method

Serves a wordpress permalink
public serve_wordpress ( )

startswith() public method

public startswith ( $haystack, $needle )

wps_filter_all() public method

Emits the details of hooks and filters as they are called, if required
public wps_filter_all ( $hook )

wps_filter_parse_query() public method

Emits page parameters
public wps_filter_parse_query ( $query )

wps_filter_query() public method

Emits all queries to the console
public wps_filter_query ( $query )

wps_filter_shutdown() public method

Runs right at the end of execution
public wps_filter_shutdown ( )

wps_filter_template_include() public method

Emits template loads to the console
public wps_filter_template_include ( $template )

Property Details

$cb_cache public_oe property

* Used to manage a cache of hook callbacks
public $cb_cache

$done_shutdown_function public_oe property

* Flag used to ensure that only one shutdown function gets set
public $done_shutdown_function

$options public_oe property

* Stores options passed to the routing script
public $options

$request_path public_oe property

Note: For a request for a real resource (like a css file) it should be a path to an existing file. For a request for a WordPress page, it will not be.
public $request_path

$request_type public_oe property

* The type of request we're serving
public $request_type

$request_uri public_oe property

* Stores the normalised version of the requested URI's path component.
public $request_uri

$start_time public_oe property

* The time this request started being processed
public $start_time