Documentation

StandaloneRouter
in package

The StandaloneRouter allows you to run CiviCRM's "Standalone" UF with the PHP built-in server.

It is intended for local development.

Ex: php -S localhost:8000 -t srv/web/ tools/standalone/router.php

Table of Contents

Constants

ALLOW_VIRTUAL_FILES  = ';\.(jpg|png|css|js|html|txt|json|yml|xml|md|woff2)$;'

Properties

$routes  : mixed

Methods

__construct()  : mixed
addRoute()  : void
Register another route.
findCore()  : string
findPackages()  : string
findSettingsPhp()  : string
findVendor()  : string
invoke()  : bool
Invoke a civicrm route.
main()  : bool
Receive a request through the PHP built-in HTTP server. Decide how to process it.
runSetup()  : bool
sendDirect()  : string
sendError()  : bool
sendFileFromFolder()  : bool
sendRedirect()  : mixed
findFile()  : string|null

Constants

ALLOW_VIRTUAL_FILES

private mixed ALLOW_VIRTUAL_FILES = ';\.(jpg|png|css|js|html|txt|json|yml|xml|md|woff2)$;'

Properties

$routes

private mixed $routes = []

Methods

__construct()

public __construct() : mixed

addRoute()

Register another route.

public addRoute(string $regex, callable $handler) : void
Parameters
$regex : string

Regular expression to run against the request-path. Ex: ';^/foobar/(.*);'

$handler : callable

Function to call when routing the match. Receives the regex-matches as input. Ex: fn($m) => $this->sendError(500, 'This path is foobared: ' . $m[1]); The handler should return TRUE (if handled), FALSE (if skipped), or selected string constants.

findCore()

public findCore() : string
Return values
string

findPackages()

public findPackages() : string
Return values
string

findSettingsPhp()

public findSettingsPhp() : string
Return values
string

findVendor()

public findVendor() : string
Return values
string

invoke()

Invoke a civicrm route.

public invoke(string $path) : bool
Parameters
$path : string

Ex: 'civicrm/admin/foobar'

Tags
throws
CRM_Core_Exception
Return values
bool

runSetup()

public runSetup() : bool
Return values
bool

sendDirect()

public sendDirect() : string
Return values
string

sendError()

public sendError(int $code, string $message) : bool
Parameters
$code : int
$message : string
Return values
bool

sendFileFromFolder()

public sendFileFromFolder(string $basePath, string $relPath) : bool
Parameters
$basePath : string
$relPath : string
Return values
bool

sendRedirect()

public sendRedirect(mixed $path) : mixed
Parameters
$path : mixed

findFile()

private findFile(string $basePath, string $relPath) : string|null
Parameters
$basePath : string
$relPath : string
Return values
string|null

If file exists, then return the combined (absolute) path. If file does not exist, then return NULL.


        
On this page

Search results