Integrate Monk ID authentication and single sign-on for apps and websites on the server-side.

author Monk Development, Inc.
SuppressWarnings (PHPMD.ElseExpression)
package Default

 Methods

Get or set a config value. Attempts to load the config if it hasn't already been loaded.

config(string $key, mixed $value = null) : mixed
Static

Parameters

$key

string

Name of config value.

$value

mixed

New config value. Leave unset to get a config value.

Exceptions

\Exception If the config can't be loaded or is invalid.

Returns

mixedConfig value.

Load an INI config file for a specific environment.

loadConfig(string $path = null, string $environment = null) : array
Static

Parameters

$path

string

Path of INI config file to load. Leave null to read from environment's MONK_ID_CONFIG value.

$environment

string

Environment section to use. Leave null to read from environment's MONK_ID_ENV value. Defaults to development.

Exceptions

\Exception If the file doesn't exist or can't be read.

Returns

arrayLoaded config values.

Load a payload from the client-side.

loadPayload(string|array $encodedPayload = null) : array
Static

Parameters

$encodedPayload

stringarray

Encoded payload or cookies array to automatically load the payload from. Leave null to read from global $_COOKIE.

Returns

arrayDecoded and verified payload. Empty if there's no payload or it fails verification.

Check whether there's a logged in user.

loggedIn() : boolean
Static

Returns

booleanWhether there's a logged in user.

Check whether there's a logged in user.

signedIn() : boolean
Static
deprecated 1.1.0 Use `loggedIn`.

Returns

booleanWhether there's a logged in user.

Get the logged in user's email address.

userEmail() : string | null
Static

Returns

stringnullEmail address if logged in user or `null` if no logged in user.

Get the logged in user's UUID.

userId() : string | null
Static

Returns

stringnullUUID if logged in user or `null` if no logged in user.

 Constants