com\setasign\SetaFramework\Bootstrap

HttpBootstrap Class Bootstrap Http

File: /SetaFramework/src/Bootstrap/HttpBootstrap.php

Class hierarchy

Implements

  • \Psr\Http\Server\MiddlewareInterface

Summary

Constants

EVENT_POST_RUN

public const HttpBootstrap::EVENT_POST_RUN = 'bootstrap.run.post'

Will be called after the main application is finished. Also if there was an exception!

extraParams:
'bootstrap' => Bootstrap

EVENT_PRE_RUN

public const HttpBootstrap::EVENT_PRE_RUN = 'bootstrap.run.pre'

Will be called before the main application will be started.

Listeners are able to modify the route data and change the application.

extraParams:
'bootstrap' => Bootstrap
'routeData' => &array

EVENT_SHUTDOWN_HANDLER

public const Bootstrap::EVENT_SHUTDOWN_HANDLER = 'bootstrap.shutdown_handler'

Will be called after script execution finishes or exit() is called.

Note: HttpBootstrap and Bootstrap share the same shutdown-event.

Show also shutdown functions.

extraParams:
'bootstrap' => Bootstrap


Properties

$debug

protected bool Bootstrap::$debug = false

$defaultDomain

$initialized

protected bool Bootstrap::$initialized = false

$requestPathPrefix

protected string HttpBootstrap::$requestPathPrefix = ''

Prefix to be substracted from the reuqest path before it is processed by routes

$response

protected ?\Psr\Http\Message\ResponseInterface HttpBootstrap::$response

Static Methods

prepare()

public static Bootstrap::prepare (
string $configFile,
array $configParams = array ( )
): Bootstrap

Helper method if you want to call the bootstrap manually.

Parameters
$configFile : string
 
$configParams : array
 
Exceptions

Throws ConfigReaderException

registerShutdownFunction()

WARNING: This method is marked as deprecated!

Use eventManager Bootstrap::EVENT_SHUTDOWN_HANDLER directly.

public static Bootstrap::registerShutdownFunction (
callable $function
): void

You should always use this method instead of "register_shutdown_function" to prevent memory leaks in application server structure.

Parameters
$function : callable
 

start()

public static HttpBootstrap::start (
string $configFile,
array $configParams = array ( ),
\Psr\Http\Server\MiddlewareInterface[]|callable[] $middlewares = array ( )
): void

Setups everything and start the application.

Parameters
$configFile : string

Path to config file

$configParams : array
 
$middlewares : \Psr\Http\Server\MiddlewareInterface[]|callable[]

Callables must return a MiddlewareInterface. They get the arguments autowired by the GlobalDi.


Methods

__construct()

final public Bootstrap::__construct (
string $configFile,
array $configParams = array ( )
)
Parameters
$configFile : string
 
$configParams : array
 
Exceptions

Throws ConfigReaderException

__wakeup()

public Bootstrap::__wakeup (
void
): void

configureDi()

protected HttpBootstrap::configureDi (
void
): void

getDefaultDomain()

public Bootstrap::getDefaultDomain (
void
): ?string

getDi()

Returns the Di

If no Di is set, the global di will be used

getQueue()

public HttpBootstrap::getQueue (
void
): array

Returns the default queue of middlewares

getRequestPathPrefix()

public HttpBootstrap::getRequestPathPrefix (
void
): string

Gets the RequestPathPrefix

getResponse()

public HttpBootstrap::getResponse (
void
): \Psr\Http\Message\ResponseInterface

Returns the Response

If no Response is set, a new instance will be created

isDebug()

public Bootstrap::isDebug (
void
): bool

Returns whether uncatched exceptions will be shown

process()

public HttpBootstrap::process (
\Psr\Http\Message\ServerRequestInterface $request,
\Psr\Http\Server\RequestHandlerInterface $handler
): \Psr\Http\Message\ResponseInterface
Parameters
$request : \Psr\Http\Message\ServerRequestInterface
 
$handler : \Psr\Http\Server\RequestHandlerInterface
 
Exceptions

Throws \com\setasign\SetaFramework\Exception

Throws \Throwable

resetState()

public HttpBootstrap::resetState (
void
): void

setBootstrapLogConfig()

setCacheHandlerConfig()

setDatabaseConnectionConfig()

setDebug()

public Bootstrap::setDebug (
bool $debug
): void
Parameters
$debug : bool
 

setDefaultDomain()

public Bootstrap::setDefaultDomain (
?string $domain
): void
Parameters
$domain : ?string
 

setErrorController()

public HttpBootstrap::setErrorController (
string $file,
string $className
): void

Sets the errorController which will used if in run happens any error

Parameters
$file : string
 
$className : string
 
Exceptions

Throws \InvalidArgumentException If $file doesn't exist.

setLogHandlerConfig()

setRequestPathPrefix()

public HttpBootstrap::setRequestPathPrefix (
string $prefix
): void

Sets the RequestPathPrefix

Parameters
$prefix : string
 

setResponse()

public HttpBootstrap::setResponse (
\Psr\Http\Message\ResponseInterface $response
): void

Sets the Response

Parameters
$response : \Psr\Http\Message\ResponseInterface
 

setRouterDefaultValues()

Parameters
$routerDefaultValues : ?\com\setasign\SetaFramework\Config\Config
 

setSessionConfig()

setTrustedProxiesConfig()

Parameters
$trustedProxiesConfig : ?\com\setasign\SetaFramework\Config\Config
 

setupCacheBuilder()

setupDatabaseConnectionManager()

setupErrorHandler()

final protected Bootstrap::setupErrorHandler (
void
): ErrorHandler
Exceptions

Throws \Throwable

setupLogBuilder()

setupLogHandler()

setupStoragelessMiddleware()

final public HttpBootstrap::setupStoragelessMiddleware (
void
): \PSR7Sessions\Storageless\Http\SessionMiddleware

shutdownFunction()

protected Bootstrap::shutdownFunction (
void
): void