Methods
public
__construct (array $defaults = [] )
#
public
setExecutorFactory (ExecutorFactory $factory ): void
#
public
getExecutorFactory (): ExecutorFactory
#
protected
setupTemplateDirs (): void
#
protected
callBeforeExit (): void
#
public
callExit (): never
#
protected
caughtException (Throwable $exception ): void
#
public
getRequest (): ServerRequestInterface
#
public
hasRequestQueryParam (string $key ): bool
Check if a specific GET parameter exists in the HTTP request.
Check if a specific GET parameter exists in the HTTP request.
#
public
tryGetRequestQueryParam (string $key ): ?string
Try to get the value of a specific GET parameter from the HTTP request.
Try to get the value of a specific GET parameter from the HTTP request.
#
public
getRequestQueryParam (string $key ): string
Get the value of a specific GET parameter from the HTTP request.
Get the value of a specific GET parameter from the HTTP request.
#
public
hasRequestPostParam (string $key ): bool
Check if a specific POST parameter exists in the HTTP request.
Check if a specific POST parameter exists in the HTTP request.
#
public
tryGetRequestPostParam (string $key ): ?string
Try to get the value of a specific POST parameter from the HTTP request.
Try to get the value of a specific POST parameter from the HTTP request.
#
public
getRequestPostParam (string $key ): mixed
Get the value of a specific POST parameter from the HTTP request.
Get the value of a specific POST parameter from the HTTP request.
#
public
hasRequestUploadedFile (string $key ): bool
Check if a specific uploaded file exists in the HTTP request.
Check if a specific uploaded file exists in the HTTP request.
#
public
tryGetRequestUploadedFile (string $key ): ?UploadedFileInterface
Try to get a specific uploaded file from the HTTP request.
Try to get a specific uploaded file from the HTTP request.
#
public
getRequestUploadedFile (string $key ): UploadedFileInterface
Get a specific uploaded file from the HTTP request.
Get a specific uploaded file from the HTTP request.
#
public
getResponse (): ResponseInterface
#
protected
assertHeadersNotSent (): void
#
public
setResponseStatusCode (int $statusCode ): $this
#
public
setResponseHeader (string $name , string $value ): $this
#
public
terminate (string|StreamInterface |array $output = '' ): never
Will perform a preemptive output and terminate. Do not use this
directly, instead call it form Callback, JsCallback or…
Will perform a preemptive output and terminate. Do not use this
directly, instead call it form Callback, JsCallback or similar
other classes.
Parameters
$output
Array type is supported only for JSON response
#
public
terminateHtml (string|array|View |HtmlTemplate $output ): never
#
public
terminateJson (string|array|View $output ): never
#
public
initLayout (Layout |array $seed ): $this
Initializes layout.
#
public
initIncludes (): void
Initialize JS and CSS includes.
Initialize JS and CSS includes.
#
public
addStyle (string $style ): void
Adds a <style> block to the HTML Header. Not escaped. Try to avoid
and use file include instead.
Adds a <style> block to the HTML Header. Not escaped. Try to avoid
and use file include instead.
Parameters
$style
CSS rules, like ".foo { background: red }".
#
public
add (AbstractView $object , string|array|null $region = null ): ($object is View ? View : AbstractView )
Add a new object into the app. You will need to have Layout first.
Add a new object into the app. You will need to have Layout first.
#
public
run (): void
Runs app and echo rendered template.
Runs app and echo rendered template.
#
public
loadTemplate (string $filename ): HtmlTemplate
Load template by template file name.
Load template by template file name.
#
protected
createRequestPathFromLocalPath (string $localPath ): string
#
public
stickyGet (string $name , bool $isDeleting = false ): ?string
Make current get argument with specified name automatically appended to all generated URLs.
Make current get argument with specified name automatically appended to all generated URLs.
#
public
stickyForget (string $name ): void
Remove sticky GET which was set by stickyGet.
Remove sticky GET which was set by stickyGet.
#
public
url (string|array<0 |string, string|int|false> $page = [] , array<string, string> $extraRequestUrlArgs = [] ): string
Build a URL that application can use for loading HTML data.
Build a URL that application can use for loading HTML data.
Parameters
$page
URL as string or array with page path as first element and other GET arguments
$extraRequestUrlArgs
additional URL arguments, deleting sticky can delete them
#
public
jsUrl (string|array<0 |string, string|int|false> $page = [] , array<string, string> $extraRequestUrlArgs = [] ): string
Build a URL that application can use for JS callbacks. Some framework integration will use a different routing…
Build a URL that application can use for JS callbacks. Some framework integration will use a different routing
mechanism for non-HTML response.
Parameters
$page
URL as string or array with page path as first element and other GET arguments
$extraRequestUrlArgs
additional URL arguments, deleting sticky can delete them
#
public
isJsUrlRequest (): bool
Request was made using App::jsUrl().
Request was made using App::jsUrl().
#
public
requireJs (string $url , bool $isAsync = false , bool $isDefer = false ): $this
Adds additional JS script include in application template.
Adds additional JS script include in application template.
Parameters
$isAsync
whether or not you want Async loading
$isDefer
whether or not you want Defer loading
#
public
requireCss (string $url ): $this
Adds additional CSS stylesheet include in application template.
Adds additional CSS stylesheet include in application template.
#
public
redirect (string|array<0 |string, string|int|false> $page , bool $permanent = false ): void
A convenient wrapper for sending user to another page.
A convenient wrapper for sending user to another page.
#
public
jsRedirect (string|array<0 |string, string|int|false> $page , bool $newWindow = false ): JsExpressionable
Generate action for redirecting user to another page.
Generate action for redirecting user to another page.
#
public
isVoidTag (string $tag ): bool
#
public
getTag (
string $tag ,
array<0 |string, string|bool> $attr = [] ,
string|array<int, array{0: string, 1?: array<0 |string, string|bool>, 2?: (string|array|null)}|string>|null $value = null ,
): string
Construct HTML tag with supplied attributes.
Construct HTML tag with supplied attributes.
$html = getTag('img/', ['src' => 'foo.gif', 'border' => 0])
--> " "
The following rules are respected:
all array key => val elements appear as attributes with value escaped.
getTag('input/', ['value' => 'he"llo'])
-->
true value will add attribute without value
getTag('td', ['nowrap' => true])
-->
false value will ignore the attribute
getTag('img/', ['src' => false])
-->
passing key 0 => "val" will re-define the element itself
getTag('div', ['a', 'href' => 'picture'])
-->
use '/' at end of tag to self-close it (self closing slash is not rendered because of HTML5 void tag)
getTag('img/', ['src' => 'foo.gif'])
-->
if main tag is self-closing, overriding it keeps it self-closing
getTag('img/', ['input', 'type' => 'picture'])
-->
simple way to close tag. Any attributes to closing tags are ignored
getTag('/td')
-->
7b. except for 0 => 'newtag'
getTag('/td', ['th', 'align' => 'left'])
-->
using $value will add value inside tag. It will also encode value.
getTag('a', ['href' => 'foo.html'], 'click here >>')
--> click here >>
pass array as 3rd parameter to nest tags. Each element can be either string (inserted as-is) or
array (passed to getTag recursively)
getTag('a', ['href' => 'foo.html'], [['b', 'click here'], ' for fun'])
--> click here for fun
extended example:
getTag('a', ['href' => 'hello'], [
['b', 'class' => 'red', [
['i', 'class' => 'blue', 'welcome']
]]
])
--> welcome '
#
public
encodeHtml (string $value ): string
Encodes string - convert all applicable chars to HTML entities.
Encodes string - convert all applicable chars to HTML entities.
#
public
decodeJson (string $json ): mixed
#
public
encodeJson (mixed $data , bool $forceObject = false ): string
#
public
renderExceptionHtml (Throwable $exception ): string
Return exception message using HTML block and Fomantic-UI formatting. It's your job
to put it inside boilerplate HTML…
Return exception message using HTML block and Fomantic-UI formatting. It's your job
to put it inside boilerplate HTML and output, e.g:.
$app = new App();
$app->initLayout([Layout\Centered::class]);
$app->layout->template->dangerouslySetHtml('Content', $e->getHtml());
$app->run();
$app->callBeforeExit();
#
protected
setupAlwaysRun (): void
#
protected
emitResponse (): void
#
protected
outputResponse (string $data ): void
#
protected
outputLateOutputError (LateOutputError $exception ): never
#
private
outputResponseHtml (string $data ): void
Output HTML response to the client.
Output HTML response to the client.
#
private
outputResponseJson (string|array $data ): void
#
Properties
public
array|false
$cdn = [
'atk' => '/public' ,
'jquery' => '/public/external/jquery/dist' ,
'fomantic-ui' => '/public/external/fomantic-ui/dist' ,
'flatpickr' => '/public/external/flatpickr/dist' ,
'highlight.js' => '/public/external/@highlightjs/cdn-assets' ,
'chart.js' => '/public/external/chart.js/dist' ,
]
Location where to load JS/CSS files
Location where to load JS/CSS files
#
protected
ExecutorFactory
$executorFactory
App wide executor factory object for Model user action.
App wide executor factory object for Model user action.
#
public
string
$version = '5.1-dev'
Version of Agile UI
#
public
string
$title = 'Agile UI - Untitled Application'
Name of application
#
public
Layout
$layout
the top-most view object
#
public
string|array
$templateDir
Set one or more directories where templates should reside.
Set one or more directories where templates should reside.
#
public
bool
$catchExceptions = true
Will replace an exception handler with our own, that will output errors nicely.
Will replace an exception handler with our own, that will output errors nicely.
#
protected
bool
$catchRunawayCallbacks = true
Will display error if callback wasn't triggered.
Will display error if callback wasn't triggered.
#
protected
bool
$alwaysRun = true
Will always run application even if developer didn't explicitly executed run();.
Will always run application even if developer didn't explicitly executed run();.
#
public
bool
$runCalled = false
Will be set to true after app->run() is called, which may be done automatically on exit.
Will be set to true after app->run() is called, which may be done automatically on exit.
#
private
bool
$exitCalled = false
Will be set to true after exit is called.
Will be set to true after exit is called.
#
public
bool
$isRendering = false
#
public
Ui
$uiPersistence
#
public
View |null
$html
For internal use
#
public
LoggerInterface |null
$logger
Target for objects with DebugTrait
Target for objects with DebugTrait
#
public
Persistence |Sql
$db
#
public
SessionManager
$session
#
private
ServerRequestInterface
$request
#
private
ResponseInterface
$response
#
protected
string
$urlBuildingIndexPage = 'index'
If filename path part is missing during building of URL, this page will be used.
Set to empty string when when your…
If filename path part is missing during building of URL, this page will be used.
Set to empty string when when your webserver supports index.php autoindex or you use mod_rewrite with routing.
#
protected
string
$urlBuildingExt = '.php'
Remove and re-add the extension of the file during parsing requests and building URL.
Remove and re-add the extension of the file during parsing requests and building URL.
#
public
bool
$callExit = true
Call exit in place of throw Exception when Application need to exit.
Call exit in place of throw Exception when Application need to exit.
#
protected
array<string, bool>
$stickyGetArguments = ['__atk_json' => false , '__atk_tab' => false ]
global sticky arguments
#
public
class-string
$templateClass = HtmlTemplate ::class
#