Microbe is a Skinny PHP framework
Hash d7ee10a4e723cc8d1b3cffe6e155bf5338935e0ca756a4062ec791750ece0eb1
Version 2622
File microbe.php
$ mkdir myproject$ cd myproject$ curl -s https://microbe.barbichette.net/require | php$ php microbe.php core setup web$ php microbe.php core setup config$ php microbe.php core setup tree$ php microbe.php core setup sampleshttp://…/microbe.php
<?php
require_once __DIR__ . DIRECTORY_SEPARATOR . 'microbe.php';
boot('web'); // boot('cli');
Register an event listener. The optional third argument is custom data array which will be passed to the function as second argument when the event is fired.
Event name.
Listener function, which will accept two arguments: event data and listener data.
Listener data.
Dispatch an event to all the listeners, with optional event data.
Event name.
Optional event data.
Register a filter listener.
Filter name.
Listener function, which will accept the data to filter as unique argument.
Dispatch a filter request to all the filter listeners.
Filter name.
Data which will be send and processed by the listeners.
Additional arguments, unchanged on each filter call.
Register an entry of something in memory (e.g. an array or an object describing anything). The collection will be able to be retrieved with <get_registered_things()>.
Thing type.
Data to store.
Save thing in array as $key. If null, the things array will be considerated as a numeric array.
Remove all registered things of type $thing.
Thing type.
Returns all registered things of type $thing.
Thing type.
Returns the registered thing where its array or object's $prop equals $value.
Thing type.
Thing's property name.
Property value.
Key of the thing.
Index of the thing. The array will be forced as a numerical-array.
Check if the permission status is one of the valid ACL_* constants.
Status to check.
Register an ACL permission, which will be used to edit permissions of a user or a role.
Internal name of the permission.
Pretty name/title of the permission.
Detailled description of what the permission allows to do.
Icon name representing the permission.
Default value of the permission: ACL_ALLOWED or ACL_DISALLOWED.
Returns the registered ACL permissions.
Returns a specific registered ACL permission.
Internal name of the permission.
Register a ACL validator function, used to check if the current visitor is allowed to perform an action.
Name of the validator source (e.g. user_role).
Function called to validate the action. This function should accept one argument: the permission name. Then, the function should return a boolean meaning if the current visitor was allowed to perform the action requiring the permission, or not.
Returns registered ALC validators.
Execute registered ACL validators to ask them if the current visitor is allowed to perform the action requiring the permission(s).
Permission(s) name(s).
Do the exact opposite of <is_allowed()>.
Permission(s) name(s).
Check if the user is allowed to perform the action requiring the permission(s). If it's OK, the function returns nothing. If it's not, the user will be either:
Redirected to $redirect if provided;
Shown a 403 error.
Permission(s) name(s).
Redirect URL.
If true, user will be redirected to login page.
If true, and if user is logged in, the user will be shown a 403 error even if $redirect is not not null or $login is true.
Get the action parameter name.
Set the action parameter name (default is 'action').
Parameter name.
Get the currently requested action name.
Register an action, known as a controller $_GET/$_POST drived.
Name(s) of the action(s) (value of get(get_action_param())).
Function to execute if the action is ran.
Register the default action, an alias of default_action('', ...).
Function to execute if the action is ran.
Returns the authentication cookie name. This name can be set with the sibling function <set_auth_cookie_name>.
Set the authentication cookie name.
New name of the cookie. If null, the default name hardcoded in <get_auth_cookie_name> will be used.
Set authentication cookie default lifetime. This behaviour can be bypassed when setting authentication token (e.g. for unremembered logins).
TTL in seconds
Register user getter callback function. This function will be called when calling <get_logged_in_user>, with the authenticated token as parameter.
Function to call from <get_logged_in_user>.
Set authentication token. The token will be stored in a cookie named with <get_auth_cookie_name>, with the lifetime given in second parameter, or the one set with <set_auth_cookie_lifetime> or finally two month as hardcoded.
Token to store. If null, cookie will be cleared (aka logout) - cf <clear_auth_token>.
TTL in seconds
Clear authentication token cookie. Used for logout.
Returns authentication token currently stored in cookie, or null.
Registers the default url where the user will be redirected when asserting login (<assert_logged_in>).
URL to redirect. If null, an exception may be thrown if <assert_logged_in> needs it.
Try to get the authentication token, then try to call the user getter function defined with <register_user_getter> with the token as unique parameter. If this function is not defined, an exception will be thrown. If the user is not logged in, null will be returned. In other cases, the function result will be returned.
Check if the user is logged in, based on <get_logged_in_user> and returns the corresponding boolean.
Check if the user is logged in. If yes, the user got from the function defined by <register_user_getter> will be returned. If not, three cases:
$redirect is null: the user will get a HTTP 403 error.
$redirect = ':login': the user will be redirected to the defined URL with <register_not_logged_in_redirect>.
$redirect = ':json': a JSON error with 'unauthorized' as message will be echoed.
$redirect is different: the user will be redirected to this URL.
[description]
Returns backup target directory.
As absolute path (useful if relative path is set in config file).
Returns backuped files.
Backup target directory.
Run backup.
Returns an array containing the defined bundles.
Refresh the bundles. If false (default), it will get the bundles infos from the ones stored in memory.
Returns all bundles directories, for each synonym available.
Check if a bundle exists or not.
Bundle name.
Refresh the bundle info stored in memory.
Returns information about a bundle.
Name of the bundle.
Refresh bundle info, or get information previously stored in memory.
Synonym used (bundle folder).
Returns all files of a specific type (helpers, ctrl, etc.) of all bundles.
Type of file (helpers, ctrl, etc.).
Includes all files of a specific type (helpers, ctrl, etc.) of all bundles.
Type of file (helpers, ctrl, etc.).
Require once instead of simply require.
* @param string $key Cache key.
Time-to-live.
Parse and stringify as JSON.
Parse the JSON as an object. If false, it will be parsed as an array.
Saving mode (only "file" is handled yet).
Load the configuration file and store it to the global variable '$_CONFIG'.
Load specific configuration file and returns the processed array.
Path to the configuration file.
Process the configuration array to replace the special variables:
The string '{@...}' will be replaced by the corresponding config entry;
The string '%env(dev,staging)' will be replaced by the boolean true if the environment is one of those listed ('dev' or 'staging', here);
Process a string to replace all configuration references identified with "{@...}".
String to process.
Get/Set configuration entry.
Entry name, separated with dots for walking deeply in the config array. The first column (the part before the first dot) should start with '@'. If not, the full path will be prefixed with '@app', corresponding to the app's specific entries. By default, a missing configuration entry will exit the code with an error. To get a silent null instead, the path should be prefixed with a '~'.
To set the value, specify anything different than the default value. It should be any JSON stringifyable value.
Echo configuration value
Entry name, like in <cfg()>.
Echo an escaped configuration value
Entry name, like in <cfg()>.
Store some data during the processing of the request, using the configuration function, inside the <@stored> configuration section.
Entry name, separated with dots for walking deeply in the config array.
To set the value, specify anything different than the default value. It should be any JSON stringifyable value.
Get/Set configuration entry from database key/value table.
Key of the entry to get or set.
Value to store in database. If null, no change will be done and the existing value in database will be returned.
Set configuration entry from database key/value table. If $value is null, the configuration entry will be deleted.
Key of the entry to set.
Value to store in database. If null, the entry will only be deleted.
Echo configuration value from database key/value table.
Key of the entry to get or set.
Echo an escaped configuration value from database key/value table.
Key of the entry to get or set.
Delete a configuration entry from database key/value table.
Entry key.
Drop the config table if there is no more entry.
Get/Set a cookie.
Name of the cookie.
Value to set. If null, the current value of the cookie will be returned.
TTL of the cookie in seconds.
Samesite property for the cookie: 'None', 'Lax' or 'Strict'.
Ask to the browser to send the cookie only through HTTPS.
If true, will disallow JavaScript to read the cookie.
Domain name. If null, it will be set to the top-level domain name.
Define a cookie configuration for further usage with <defined_cookie> and Microbe_Cookie instance.
Name of the cookie configuration.
Name of the cookie. If null, $name will be used. In case of multiple cookie, the cookie index is defined in the name using the substring Microbe_Cookie::IDX_SUBSTRING.
Cookie's time-to-live in seconds or a duration string.
Multiple cookie or not?
Domain configuration: 'current' or 'top'.
Modifier callback function, which will be applied on cookie's values.
Get a defined cookie's Microbe_Cookie instance.
Name of the cookie configuration.
Get the defined cookies.
Set the defined cookies.
Key-value array containing Microbe_Cookie instances.
Returns the database config as an object.
Returns the DSN string of the database connection.
Create a PDO object based on the entries in configuration.
The database reference. Default is 'main'.
The configuration object. Default is the one set in the configuration file, for the current environment.
Force renewal of PDO object.
Get last PDO connection error if available.
Get the current PDO object, and try to instanciate one if not created yet.
The database reference. Default is 'main'.
Check if the PDO instance is initialized or can be initialized.
The database reference. Default is 'main'.
Get the PDO argument type, based on the given value, before binding it to the PDOStatement.
Value to check.
Optional parameter key, for debugging purpose.
Optional SQL query, for debugging purpose.
Escape the parameter value for usage in MySQL strings.
Value.
Check if the format of the field name is a proper MySQL table or column name. Only the format will be checked. Not the field existence. It can be used to protect a query from SQL injection, when the table name or the column name can be passed through a form.
Table or column name.
Check if the format of the field name is a proper MySQL table or column name using <db_is_valid_field_format> to avoid SQL injection. If the format is invalid, an exception will be thrown.
Table or column name.
Check if the given string is a valid SQL comparator.
Possible comparator string.
Check if the given string is a valid SQL comparator. If the format is invalid, an exception will be thrown.
Possible comparator string.
Prepare the PDOStatement based on the SQL query and the given variables.
The SQL query.
A key/value associative array with the variables to replace in the query. Note: the variables should be prefixed with a semicolon in the SQL.
The database reference. Default is 'main'.
Returns the last query if available.
Returns the last PDO statement if available.
Compute SQL with parameters and returns a ready-to-use query.
SQL query.
Parameters to be applyed on query.
Read a SQL file and execute queries.
Path to the SQL file.
Create a dump file of the database.
Destination SQL file path.
Get database's size.
Get database's tables infos.
Returns number of rows for each table.
Returns an associative array with table name as key.
Delete all tables.
First, drop all foreign keys, or not.
Get all foreign keys from the database.
Delete all foreign keys from the database.
Check if the table exists.
Table name.
Check if the column exists in given table.
Table name.
Column name.
Execute a <db_query> and fetch all the rows as an object.
SQL Query.
Query variables.
An optional modifier callback, called on each row. The modifier should take the $row as unique argument, and return the modified $row.
Execute <db_fetch_all> and returns the first row. Note that this function doesn't assert that the SQL query limits the result to only one result, so the calling to <db_fetch_all> will be very long if the SQL is not adapted.
SQL Query.
Query variables.
An optional modifier callback, called on each row. The modifier should take the $row as unique argument, and return the modified $row.
Fetch the first column's value of the first row of the database query, after calling <db_fetch_one>.
SQL Query.
Query variables.
An optional modifier callback, called on each row. The modifier should take the $row as unique argument, and return the modified $row.
Fetch the first column's value for every row returned by <db_fetch_all>.
SQL Query.
Query variables.
An optional modifier callback, called on each row. The modifier should take the $row as unique argument, and return the modified $row.
Returns the last insert ID.
The database reference. Default is 'main'.
Generate a UID unique in the table $tableName.
Table name.
UID field name (default 'uid').
Generate a unique slug in the table $tableName. It can be based on a specified string ($text) which will be sanitized and shortened, and optionaly can take in account an original ID for the object which will get its slug (should be provided if the slug may not change).
Table name.
Base text (default, a random SHA-1 string).
ID of the object which should take the slug.
Slug field name (default 'slug').
ID field name (default 'id').
Additional WHERE conditions.
Returns a ready-to-use "Y-m-d H:i:s" now time string for database usage.
Check if the table exists, and optionnaly if the column in this table exists.
Table name to check.
If not null, will also check if the column name exists in this table.
Set FOREIGN_KEY_CHECKS to the specified value.
Check or not.
Build a WHERE clause based on a key/value array, where the value can be represented by a scalar value which should match, or an array or an object with the properties 'comparision' and 'value'. The 'comparision' should be one of those tested in <db_is_valid_comparator>.
Key/Value array with the conditions.
Get the last (maximum) position for a given rows set.
Table name.
Where conditions as a key/value array.
Column name of the position (default 'position').
Get the last (maximum) position for a given rows set, and at 1.
Table name.
Where conditions as a key/value array.
Column name of the position (default 'position').
Set a new position for a given element in a rows set.
Table name.
ID of the item we want to move.
New position to set, as an index or a special position string: 'first', 'last', 'up' and 'down'.
Where conditions as a key/value array.
Column name of the position (default 'position').
Column name of the ID (default 'id').
Cleanup the positions for the given set.
Table name.
Where conditions as a key/value array.
Column name of the position (default 'position').
Column name of the ID (default 'id').
Search in database, in all columns of all tables (or specified with $tables).
Search term.
Search mode: equals, like or like_jokers.
Tables included for search.
Select query offset.
Select query limit (null for unlimited).
Returns the ID of a given entity. It will not check if the $entity is the proper entity, but returns an integer corresponding to what seems to be the ID, or null if the $entity cannot be matched to an integer or an object or a Microbe_Entity instance containing an ID.
[description]
Name of the associated class. If given, the method fetchOneMixed will be called.
Property name.
Throw exception if unable to get the ID.
Returns a new Microbe_Query_Builder instance, which can be instanciated with a specific table name and alias.
Name of the first/main DB table.
Alias of this table.
Returns an array containing the migrations files informations.
Returns a database migration description, with parsed queries.
Name of the migration.
Split queries separated with semicolons.
Execute a migration.
Name of the migration
Migration direction: 'up' or 'down'.
Execute only this migration if true. If false, all the missing previous migrations will be also run.
Get/Set the current migration name.
Optional name of the migration. If false, the current migration will be reset to none.
Setup the database configuration for creating other MySQL databases and/or users.
The privileged-user's name.
The privileged-user's password.
The database reference. Default is 'setupdb'.
Try to create the MySQL user.
The privileged-user's name.
The privileged-user's password.
Try to create the MySQL database.
Display a deprecation message.
Function name.
Type of error: warning or fatal.
String representing the error and/or the migration.
Display a warning deprecation message.
Function name.
String representing the error and/or the migration.
Display a fatal deprecation message.
Function name.
String representing the error and/or the migration.
<DEPRECATED> / // ============================================================================= // ----------------------------------------------------------------------------- // -- {# Ending DEPRECATED #} -- // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // -- {# Beginning DEV #} -- // ----------------------------------------------------------------------------- // ============================================================================= // ---{ Functions }------------------------------------------------------------- /** Returns the name of the cookie used for developer tools authentication.
Check if the current visitor is allowed to access dev tools.
Check also if the cookie allows dev access.
Generate the console page for developers.
Render the HTML of the console page for developers.
Template variables.
Returns a Microbe_DOM_Element, helping to build HTML elements.
Tag name, optionnaly containing classes and ID as . and # suffixes.
Returns an array containing the useful pages numbers, and null entries for ellipsis.
Current page number.
Total pages.
Create a Microbe_Pagination instance.
Variable name.
Url format (default: url('.', [ $var => '{{page}}' ])).
Total items of the collection.
Items shown per page.
Check if the email address is valid.
String supposed to be an email address.
Parse several email addresses using <parse_email_address> for each one.
String to parse.
Parse an email address, with optionally the name and the address.
String to parse.
Parse email address, get its left part, and optionnaly tries to format the username.
String to parse (perhaps an email address).
Tries to format the username.
Obfuscate the characters of an email address except the two firsts of the username and the @... part.
Email address
Register an email carrier.
Name of the carrier.
Function called when sending an email through this carrier. $func should take three arguments:
object $cfg
object $opts
string $body
array $embeddedImages
Returns the email carrier object currently in use.
Send an email.
Process the body string, to find the src="@cid{...}" or src="@base64{...}" images and process it. An object with the new body and the @cid attachments will be returned. The @cid will be replaced by a src="cid:{sha1_of_the_path}", and this identifier will be returned as a key of the returned attachments, with the file path as a value. The @base64 images will be replaced by an inline src, base64 encoded.
Body string.
If the debug mode is enabled, the image will be kept unchanged, to be able to see it in a browser display.
Returns an array of stored emails (years-months or HTML files).
Year-Month. If not provided, available years-months will be returned instead of HTML files.
Returns an array of valid environments names.
Check if the given environment name is a valid one.
Environment name.
Get and returns the current environment, based on the '/ENV' file. If this file is not found, or empty, 'prod' will be returned.
Set current environment via /ENV file.
Check if the current environment is one of those given in arguments.
Environment name (or several, as different args).
Returns the directory where the framework's file is located, which is assumed to be the root directory of the project.
Join paths parts together, using the system's directory separator (/ or \), and returns the result.
Paths parts as separated arguments.
Join paths parts together exactly like <join_path>, but prefixing the root directory got through <get_root_dir>.
Paths parts as separated arguments.
Returns the vendor directory.
Optional sub-paths parts as separated arguments.
Returns the vendor-static directory.
Optional sub-paths parts as separated arguments.
Returns the backend directory.
Optional sub-paths parts as separated arguments.
Returns the controllers directory.
Optional sub-paths parts as separated arguments.
Returns the data directory.
Optional sub-paths parts as separated arguments.
Returns the sessions directory.
Optional sub-paths parts as separated arguments.
Optional sub-paths parts as separated arguments.
Returns the cache directory.
Optional sub-paths parts as separated arguments.
Returns a cache file path.
File name with extension, with optionaly some directories before.
Returns the directory path for the temporary files, optionaly with a subdirectory (which will be created if it doesn't exists).
Subdirectory name.
Returns a temporary file path.
File name. Random string if empty.
Subdirectory name. Temp directory root if empty.
File extension.
Include all PHP files of a directory.
Directory path.
Default true. If true, the file will be required using 'require_once'. In other case, it will be 'require'.
Includes specific file type (helpers, ctrl, etc.) located at root.
Type of file (helpers, ctrl, etc.).
Require once instead of simply require.
Includes specific files type (helpers, ctrl, etc.), from root and bundles.
Type of file (helpers, ctrl, etc.).
Require once instead of simply require.
Returns the current domain name, aka HTTP hostname.
Verify is the result of <get_domain_name> match with the string or the regex pattern given.
String or regex pattern (beginning and ending with a slash, with optionnaly some letters at the end).
Returns the top level domain name (e.g. when <get_domain_name> will be 'foo.bar.tld' or 'john.doe.bar.tld', this function will return 'bar.tld'). This function can be useful with the cookies policies.
Returns the current HTTP scheme: https:// or http://.
Returns true if the current HTTP scheme is HTTPS. Else, false.
Returns the base URL, based on the $_SERVER's SCRIPT_NAME. Generally, the server configuration should redirect every request (except for existing files) to the 'index.php'. This function retrieve the directory URL to the called file, so 'index.php' and returns it. If the app is working at the root of the server (at the domain name level), an empty string will be returned. Else, the subdirectories will be returned.
Convert an absolute path into a URL.
Absolute path to a file or a directory.
Include host in URL.
Convert a URL to a local path.
URL to process.
Validate the host if the URL contains one. If true, the current host will be used. If false, every host will be allowed. If a string, it should be a regexp.
Returns the requested URL, as given by the server.
Returns the URL with scheme and domain, or only path.
Returns the referer URL if available.
Returns the current URL, without query strings.
If true, trim the slashes.
Returns the requested path, relatively to the project root. The given path should be located insidide the project folder.
Absolute path to relativize.
Returns the requested URL, based on <get_request_url>, relatively to the base URL of the app got using <get_base_url>.
Keep or strip the query strings from the URL.
Returns the HTTP method (GET, POST, PUT or DELETE).
Returns true if the current HTTP method is the one given.
Method to compare.
Returns true if the current HTTP method is POST.
Returns true if the browser sent the headers of a XMLHTTPRequest, aka ajax request.
Returns the client IP address, as given by the server.
Returns the user agent of the visitor.
Get the variable given in argument from the POST or GET data. If the argument is an array of variable names, an associative array will be returned with all the corresponding values from POST or GET.
Variable(s) name(s).
Variables passing methods ('both', 'get' or 'post')
Trim string values.
Getting the variable given in argument from the GET data. Does exactly the same as <get()>, but only get data from GET, not from POST.
Variable(s) name(s).
Trim string values.
Getting the variable given in argument from the POST data. Does exactly the same as <get()>, but only get data from POST, not from GET.
Variable(s) name(s).
Trim string values.
Key or array of keys to get with <get()>.
Modifier function. Takes two params: the value and the key.
Returns null if string is empty.
Nullable values.
Method used by <get>.
Get the variable(s), cast it to trimed string.
Key or array of keys to get with <get()>.
Trim the value.
Returns null if string is empty.
Method used by <get>.
Get the variable(s) with <get_str()>, but returns null as value if the string is empty.
Key or array of keys to get with <get()>.
Trim the value.
Get the variable(s), cast it to a number.
Key or array of keys to get with <get()>.
Don't allow floating values.
Minimum value.
Maximum value.
Returns null if string is empty.
Nullable values.
Method used by <get>.
Get the variable(s), cast it to an integer.
Key or array of keys to get with <get()>.
Minimum value.
Maximum value.
Returns null if string is empty.
Nullable values.
Method used by <get>.
Get the variable(s), cast it to an integer, in nullable mode.
Key or array of keys to get with <get()>.
Minimum value.
Maximum value.
Nullable values.
Method used by <get>.
Check if the given POST/GET param seems to be equivalent to a true, aka 1, (y)es or (t)rue.
Variable name.
Variables passing methods ('both', 'get' or 'post').
Get the given POST/GET param and check if its value is one of those specified with $values. If not, $default will be returned.
Variable name.
Allowed values.
Value returned.
Variables passing methods ('both', 'get' or 'post').
Get the POST/GET param $k and tries to build the DateTime object.
Variable name.
Get the POST/GET param $kd and tries to build the DateTime object. If $kt is given, it should corresponds to the time variable name.
Date or datetime variable name.
Time variable name.
Optional timezone.
Get some query-string passed values, which use the same name. E.g. foo.html?a=foo&a=bar&b=john => a=[foo,bar]
Variable name.
Get the variable given in argument from the POST or GET data, then cast it to an associative array. If no variable match, or the value is not a valid associative array, an empty array will be returned.
Variable name.
Variables passing methods ('both', 'get' or 'post')
Getting the variable given in argument from the GET data and cast it as an array. Does exactly the same as <get_assoc_array()>, but only get data from GET, not from POST.
Variable(s) name(s).
Getting the variable given in argument from the POST data and cast it as an array. Does exactly the same as <get_assoc_array()>, but only get data from POST, not from GET.
Variable(s) name(s).
Execute <cast_data> on $_POST.
Pattern of the data we are waiting for.
Trim string values or not (default true)?
Chained keys separator (when default one may be found in one of the key names).
Current walking key. Internal use only.
Execute <cast_data> on $_GET.
Pattern of the data we are waiting for.
Trim string values or not (default true)?
Chained keys separator (when default one may be found in one of the key names).
Current walking key. Internal use only.
Get the queried or posted page number, and cast the value to get an integer between $min and $max, with a $default value.
Value to process. If null, the value will be got from $_GET or $_POST with the key $var.
Var name corresponding to the page number requested.
Default page number.
Maximum page number.
Minimum page number.
Validate some GET/POST parameters based on the rules given in the array, then return the casted data and the errors if exists.
Numerical array containing each field and its rules, as a Closure getting the value as first parameter, and returning an error as a string or nothing if the rule passed. A special '@' key can be included, to cast the value. In this case, the return of the Closure will be the casted value.
Returns the data as an array instead of an object.
Register a custom error callback function, based on an error code.
Error code: basically 403, 404 or 500.
Callback function, executed when the $errorCode is thrown somewhere.
Option environments array: when the current environment is not in this list, the callback will not be called.
List error files.
Type of error (500, 404, 403).
Filter by year.
Filter by month.
Reverse files (default true: recent first).
Returns logged error for a specific error type and date.
Type of error (500, 404, 403).
File's year.
File's month.
File's day.
Limit results. Null for no limit.
Reverse results: recent first.
Returns path of error log file.
Type of error (500, 404, 403).
File's year.
File's month.
File's day.
Log error in local file.
Error type: 404, 403 or 500.
Optional message.
Parse an error line got from a log file.
Line as a string.
Throw a 403 error, with the registered custom handler or with a system message. Generally reached after a catching of an 'Microbe_Unauthorized_Exception'.
Message to pass to the handler or to show in the system message.
Throw a 404 error, with the registered custom handler or with a system message. Generally reached after a catching of a 'Microbe_NotFound_Exception'.
Message to pass to the handler or to show in the system message.
Throw a 500 error, with the registered custom handler or with a system message. Generally reached after a catching of any 'Exception' which is not an 'Microbe_Unauthorized_Exception' or an 'Microbe_NotFound_Exception'. In the case of an 'Microbe_Exception' which means an 'Exception' sent through this framework or the friends of it, $isExternal will stay false. When it's reached from an unmanaged Exception, $isExternal will be true.
Error details, generally given from an 'Error' or an 'Exception' instance.
Is it an error caught from a 'Microbe_Exception' or not?
Message to pass in the $err array.
Generate the HTML string for a file path entry, separating the relative URL from root and the other part of the absolute path, then appending the line number.
File path.
Line number.
Errors callback, used by <set_exception_handler>, <set_error_handler> and <register_shutdown_function>.
Error, exception or exit code.
Returns a HTML string, representing a red <div/> with the $str message.
Error message.
Returns 0755, aka the default new directory chmod.
Returns 0644, aka the default new file chmod.
Check if the path or the file name extension is not one of known non-ASCII extensions.
Path or file name.
Returns file type based on extension.
Path or file name.
Create recursively a directory.
Path of directory to create
Sanitize a filename, removing special characters and accents, and shortifying the name if too long.
Original file name.
Separator used in replacement of non-alphanumerical characters.
Maximum length of the part before the extension.
Check if a filename seems secure, without slashes, double dots, control characters, banned Windows characters and NULL character.
Filename (should probably be a string).
Returns a hashed string, suffixed optionnaly with an extension, in order to use as a filename. We replace the 'c' followed by a 'd', by a 'f' to avoid sometimes problematic 'cd'.
String to hash.
Convert a size into a human-readable value. The input size and the output size can be one of those units:
B: bytes
KB: kilobytes
MB: megabytes
GB: gigabytes
TB: terabytes
PB: petabytes
Size.
Input unit.
Output unit. If null, the detection will be made to find the most readable unit.
Remove spaces and 'B', to make a string usable for PHP or server configuration.
Returns the bytes value of an input size, which can be suffixed with one of the units returned by <bytes_unit>. E.g. '345.67MB' will return 345670000.
Size suffixed or not with a unit.
Get hash for the given file.
File path.
Force hash computing even if already stored.
Hashing algorithm.
Store computed hash.
Returns the file's extension.
File name or path.
Prepend the dot before the extension. Default false.
Lowercase the extension. Default false.
Returns true if the file extension corresponds to the given one(s).
File name or path.
Extension or array of extensions.
Removes a file's extension.
File name or path.
Returns an array containing the owner of a path (file or directory).
Path to the file or directory.
Returns the file/directory permissions as octal string (0644, 0777, etc.).
Path to the file or directory.
Returns the file/directory permissions as a human readable string.
Path to the file or directory.
Check if a given path is a valid path to a file or a folder, and if this file is properly located inside a root directory.
Path to be checked.
Base directory.
Does $path can be $root itself?
Returns the file name as an array containing the name and the extension.
File name.
Include the extension's dot or not.
Get the maximum upload size, based on the PHP configuration ('post_max_size' and 'upload_max_filesize'), and an optional configuration context defined with the configuration key '@upload.{ctx}.max_size'.
Context.
Get the maximum upload size requested by configuration.
Get uploaded files metadata, from $_FILES.
Name of the posted file field.
If false (default), it will return the uploaded file metadata as an array of objects representing each uploaded file with the given post name.
Get uploaded file metadata, from $_FILES, using <get_uploaded_files> with $one as true.
Name of the posted file field.
Move the uploaded file from its temporary path to the given one, and create the subdirectories if asked and needed.
File object got from <get_uploaded_file> or <get_uploaded_files>.
Path where the file will be saved (new file's path).
Make the (sub)directories if doesn't exists.
Perform the file upload, based on the file object got from <get_uploaded_files>. If an error occur, an 'ErrorException' will be thrown. The options are the following:
'path': The path of the new file.
'keep_filename': If true, the 'path' will be considerated as a directory and the file will be stored inside this directory with its sanitized uploaded file name. If false, the 'path' will be kept as the new file path. Default: true.
'keep_extension': If true, the extension of the uploaded will be kept, and the extension given in 'path' will be ignored. Default: true.
'letters_folders_levels': Append X levels of letter folders (e.g. when 2: '/path/to/images/a/b/abc.jpg'). Missing folders will be created. Default: 0.
'iterate_filename': Iterate to the file name if conflict. Default: true.
'iterate_format': Iteration suffix format. Default: '_%s'.
'default_folders_chmod': Default: the result of <get_mkdir_chmod>.
'default_files_chmod': Default: the result of <get_new_file_chmod>.
Upload file object.
Upload options.
Check if $path is already a file. If yes, an increment will be added to the end of the name, before the extension.
File path.
Separator between the filename and the iteration.
Check if the directory $dir is empty or not.
Directory path.
Compute directory size.
Directory path.
Returns readable size or not.
Remove a directory and its files recursively.
Path to directory.
Delete also the directory $dir itself.
Filter function, which will accept the path of the item processed. If this function returns true, the file or the directory will be deleted. If false, the item will be kept.
Path to the original directory (the initial value of $dir).
Make a file name shorter, by removing middle characters.
File name.
Maximum length. If null, the file name will not be truncated.
Send a file to the browser, with proper headers to force the download.
Path to the file
List files and folders inside a directory.
Path to directory.
Retrieve files.
Retrieve folders.
Filter regex.
List files inside a directory.
Path to directory.
Filter regex.
List folders inside a directory.
Path to directory.
Filter regex.
Read $lines lines from the end of the file.
Path of file to read.
Number of lines to get.
Read $lines lines from the beginning of the file.
Path of file to read.
Number of lines to get.
Returns the latest modified file time in a given directory.
Directory path.
Returns a new instance of Microbe_File.
Path to file.
Returns a new Microbe_Form instance.
Name of the form (useful for storing results).
Returns a new Microbe_Form_Field instance with a specific type.
One of Microbe_Form_Field::T_*.
Parent as a Microbe_Form_Element instance.
Get a form defined in a form file (located in the forms folder of each bundle). The name of the form is the name of the file. The file has to return a Microbe_Form instance, and receive optional variables given by $args.
Name of form file.
Args passed to file before including it.
Returns the Microbe file path.
Returns the Microbe file name.
Returns the version and hashes of the framework.
Parse the source code to find the meta hash.
Source code of the framework.
Parse the source code to find the source code hash.
Source code of the framework.
Parse the source code to find the version number.
Source code of the framework.
Parse the source code to find the version date.
Source code of the framework.
Generate an API URL for framework requests (e.g. Updates and Plugins Warehouse).
Action to perform on the API.
Optional query-string arguments.
Retrieve the available updates from the framework's API, based on current framework and plugins versions.
Perform an update on the framework itself.
Download URL got from <get_available_updates>.
Convert a coordinate given as a string or a set of degrees, minutes, seconds and direction, to a decimal coordinate.
Coordinate string (e.g. 1°2'3.456"W) or degrees as an integer.
If $deg is not a string: the minutes.
If $deg is not a string: the seconds.
If $deg is not a string: the direction (N, S, W/O, E). $deg can also be signed, and $dir ignored.
Convert a decimal coordinate to a string like 1°2'3.456"W.
(lat)itude or (lon)gitude.
Decimal coordinate.
Returns a string (default) or an object containing direction/degrees/minutes/seconds.
Round the seconds.
Execute <dec_coordinate_to_dms()> with $type = 'lat'.
Decimal coordinate.
Returns a string (default) or an object containing direction/degrees/minutes/seconds.
Round the seconds.
Execute <dec_lon_to_dms()> with $type = 'lon'.
Decimal coordinate.
Returns a string (default) or an object containing direction/degrees/minutes/seconds.
Round the seconds.
Create a box of coordinates, based on a center latitude and longitude, optionaly enlarged with a radius. Based on: 1 latitude-deg = 110574 (meters) 1 longitude-deg = 111320 * cos(latitude) (meters)
Decimal latitude.
Decimal longitude.
Radius in meters.
Check if the given path extension corresponds to a valid image file.
Path to the file.
Array of allowed extensions.
Returns raw data of a PNG image containing a single transparent pixel.
Resize an image.
Source image path.
Destination path. If null, nothing is written, and the Imagick instance is returned.
Destination width. If null, $width = $height. At least width or height must be provided.
Destination height. If null, $height = $width. At least width or height must be provided.
Cropping mode (MB_IMAGE_RESIZE_*).
Output quality (0-100).
Padding color, when mode is "contains".
Make directories recursively if needed.
Image generation method: "imagick".
Read the image file with the proper content type. It will guess automatically the content type.
Image path
Load the GdImage instance from image path. It will guess automatically the file type.
Image path
Save the GdImage to given path, guessing automatically the output file type.
GdImage instance.
Destination path.
Image quality if appliable.
Resize an image and returns the path of the created file.
Path of source image.
Destination width. If null, $width = $height. At least width or height must be provided.
Destination height. If null, $height = $width. At least width or height must be provided.
Cropping mode (MB_IMAGE_RESIZE_*).
Output quality (0-100).
Force cache refreshing.
Resize an image width <get_resized_image_path()> and returns the URL of the created file.
Path of source image.
Destination width. If null, $width = $height. At least width or height must be provided.
Destination height. If null, $height = $width. At least width or height must be provided.
Cropping mode (MB_IMAGE_RESIZE_*).
Output quality (0-100).
Force cache refreshing.
Create a thumbnail of an image image and returns its path.
Path of source image.
Thumbnail width and height.
Create a thumbnail of an image image and returns its URL.
Path of source image.
Thumbnail width and height.
Generate a random image.
Width of image.
Height of image. Default is equals to width.
Path to save file. If null, the image will be rendered in the browser.
Maximum number of shapes. More: the image will be more complex. Less: the image will be faster to render.
Output mode. 'auto' will switch between direct rendering or saving to $path if provided. Possible values are:
auto
display: display in browser
write: write to $path
gd: returns GdImage instance
raw: returns image's raw code
base64: returns image base64-encoded
Retrieve the accepted languages sent by the browser, parse it and try to match with the locales handled by the framework.
Returns an array containing the valid locales existing in the configuration file. The locale will be constructed from the countries and the languages codes, then the valid ones will be returned.
Force the renewing of the locales in the memory cache.
Returns a specific app locale. The returned locale will be one of the locales defined in the configuration file.
Locale code.
Get the app locales using <get_app_locales()> and returns the default one.
Returns the current locale, based on:
user configured locale, stored in cookie;
first valid browser's accepted locale;
default locale.
Set current app locale in cookies.
Locale code.
Returns translation variables.
Set translation variables, which will be applied on each string passed to <t()>.
Key-value array of variables.
Declare current locale in use with <t()>.
Locale name.
Returns the current locale name for translatable strings through <t()>.
Translate a string, with an optional formatting of the string with the passed variables.
String to translate. If an array is given, this array have to be a numerical-keys array with 1, 2 or 3 entries. If there is 1 entry, the format will be considered as non-array. If there is more entries, a parameter in $vars matching 'n', nb', 'num', 'number' or 'count' will be considered as a counter. If there is no match, the first parameter found will be considered. Then, with a 2-entries array, $format[0] = $format if counter is 1; $format[1] = $format if counter is 0 or > 1. With a 3-entries array: $format[0] = $format if counter is 0; $format[1] = $format if counter is 1; $format[2] = $format if counter is > 1.
Variables to process in string. If this is an associative array, the keys will be replaced in the string using brackets like: {foo} or {{foo}}. The double-bracket will be replaced by an escaped string. If string is provided, we assume $vars corresponds to $fromLocale.
Locale to be translated to.
MMMMMMM.
Translate a string, exactly like <t>, then echo the translation.
String to translate.
Variables to process in the string. *
String to translate.
Variables to process in string. If string is provided, we assume $vars corresponds to $fromLocale.
Locale to be translated to.
MMMMMMM.
Translate a string, exactly like <t>, escape it, then echo the translation.
String to translate.
Variables to process in the string. *
String to translate.
Variables to process in string. If string is provided, we assume $vars corresponds to $fromLocale.
Locale to be translated to.
MMMMMMM.
Load the translation file and store translations in an array.
Locale code.
Force the refresh of the memory-saved translations.
Store a translation entry in the bundle's translation file for the specified locale.
Locale code.
Original text.
Translated text.
Bundle name. Default is 'default'.
Clear memory-saved translations for this locale.
Sotre an internationalizable string, in a simple XML file.
Translatable string.
Get the list of all handled countries.
Retrieve info about a specific country.
Country object or code, with 2 (ISO 639-1) or 3 (ISO 639-2) character.
Returns the regex which can be used to validate a postcode. It will be a simple regex compatible with all countries.
Check if a postcode is valid. If country is provided
Postcode to validate.
Country object or code. If null, the default postcode regex will be used.
Cast a given value to a phone number. If the value is not readable, null will be returned.
Input phone number.
Prefix automatically a dialing code.
User the phone casting function to check if the phone number is valid.
Input phone number.
Check if a given value is a valid postcode and clean it.
Possibily a postcode.
Get the list of all the handled languages.
Retrieve info about a specific language.
Country code, with 2 (ISO 639-1) or 3 (ISO 639-2) character.
Retrieve all the possible languages combinations, aka lang mixed with countries where it can be spoken.
Get a specific locale, based on its code (aka xxx-XXX).
Locale code.
Get the flag of a country, as a SVG string, based on its 3-char code (aka ISO 639-2).
3-char code of the country.
Returns the string ready to include in a HTML src="" attribute.
Log something.
Name of the log.
Message to log.
Max size of each log file. Null for unlimited.
Path of the log file to write in (if using this parameter, will ignore $maxSize).
Convert some floating number to a "human-readable" fraction/ratio.
Floating number.
Roundable tolerancy.
Process a string containing some fractional value (e.g. 50/100 returns 0.5).
Fractional string.
Returns given URL with a random parameter.
URL to process.
Random parameter name.
Check if a URL seems valid.
Something which should be a URL.
Allows URLs without hosts.
Try to get all URLs in a specified string.
String to process..
Check if a local path can be matched.
Validate the URL with a custom regex.
URL or domain name.
Probable domain name.
Check if a string is a valid domain name, including subdomains.
Probable domain name.
Tries to retrieve a file name from a given URL.
URL.
Execute a cURL request.
Url to fetch.
HTTP method (GET, POST, DELETE, etc.)
Query strings to pass in URL if $method is GET, or postfields added to the request.
Parse result as JSON data.
Array of headers to pass to request.
Array of cookies to pass to request.
Maximum number of redirects.
Verify peer certificate or not.
User agent. If true, a standard user agent will be set.
Perform a cURL GET request.
Url to fetch.
Postfields added to the request.
Parse result as JSON data.
Verify peer certificate or not.
Path where to store the result.
Array of headers to pass to request.
User agent. If true, a standard user agent will be set.
Perform a cURL POST request.
Url to fetch.
Postfields added to the request.
Parse result as JSON data.
Verify peer certificate or not.
Returns the last cURL error (when used <curl_get> or <curl_post>).
Returns the last cURL info (when used <curl_get> or <curl_post>).
The key of the info to get.
Returns the last cURL response (when used <curl_get> or <curl_post>).
Declare or update a global template variable.
Name of the variable
Value or new value of the variable.
Set multiple global template variables.
Key/Value array container variables to declare/update.
Replace
Delete a global template variable.
Key of the template variable to delete.
Returns all the global template variables.
Returns a specific global template variable value.
Key of the template variable.
Render a template.
If the given template path is prefixed with a '/', the path of the looked-up file will be relative to the project root. Else, it will be relative to the '/tpl' directory.
If the path doesn't has a recognized extension (phtml, php, html or htm), the path will be suffixed with '.phtml';
Template name/path.
Variables to inject to the template. They will be merged to the global template variables.
Returns the result as a string if true. Else, it will be echoed.
Preprocess the assets if needed, depending on the configuration. If false, the assets preprocessing will be fully skipped.
Dispatch the events or not.
Throw an error when the template file is missing.
Exit the code with <close()> after rendering.
Outputs a JSON oject containing the HTML and the underscored variables. Can be a boolean or 'auto'.
Update global template vars with $vars.
Load global template into template.
Render a template with <render>, only if the current HTTP request is not a XMLHTTPRequest.
Template name/path.
Variables to inject to the template.
Render a template traditionnaly located in 'widgets' subfolder. This is very close to <render()>, but with the purpose of reusable components taking simple arguments, or only one argument.
Name of the template. If starting with a '@', a standard template path is expected. In other cases, the template will be looked for in the default bundle directory, under templates/widgets.
Single argument, or key-value array containing several template variables.
Returns the template as a string, or echo it directly.
Begin a template part, which can be reused in another part of the template.
Name of the template part.
Ends the template part and store the content without displaying it.
Returns the template part previously stored.
Name of the template part.
Display the result of <get_tpl_part>.
Name of the template part.
Render a template based on function echoing some HTML.
The template vars or the echoing function.
The echoing function or the template vars.
Register a template, based on a name and a source code as a string.
Name of the template.
Function echoing the template code (PHP/HTML).
Returns an inline template rendering function, based on its name.
Name of the inline template.
Returns an absolute path corresponding to the asset given as argument.
Asset's path, relative to the project, which can contains a bundle reference.
Generate the proper <link> or <script> code to include the given path.
Path to asset file (absolute or relative to assets root).
Array containing additional HTML attributes to append to the asset tag.
Returns as a string. If false (default), echo the HTML.
Generate the proper <link> or <script> code to include the given path.
Paths to assets files (absolute or relative to assets root).
Ask for an asset. In the standard use case with a context template (e.g. homepage), loading the header and the footer with <layout>, this function can be executed immediatly before running <layout>('...header...'). Like this, if the header or the footer are using <is_asset_needed> with the proper asset name, this asset will be handled.
Name of the asset.
Always true, except if you finaly want to disable this asset.
Check if an asset is asked somewhere.
Name of the asset.
Returns the path of the file containing the assets version number.
Returns the current assets version number, as written in the assets version file.
Check if the environment is excluded from assets caching (e.g. 'dev'). If yes, a random string will be returned instead of a specific number.
Increments the assets version number.
Increment by how many? Default 1.
Returns the path of the file containing the last asset file modified time.
Returns the latest asset file modified time.
Set the latest asset file modified time.
Returns all assets directories (root and bundles ones).
Get the DateTime of the latest asset file modification time.
Execute the assets preprocessors, like Stylus, SASS, LESS, etc.
Preprocess even if it was already done before in this request.
Require some JavaScript files in the proper <script/> tag(s).
Array of relative paths to the *.js files from the root of the project. It can ends by a "/*" to load all the files contained in a specific directory.
Bind the files together, instead of requiring them through separated <script/> tags.
Minify a bit each files before binding. It will does nothing if the binding is not enabled.
Always use the cache if the files were unchanged, or regenerate it each time.
Declare some CSS rules, for further inline use (in style="...").
Key/Value CSS rules. The key is the name of the rule, and the value is a string containing some CSS declarations, or an associative array representing those declarations. E.g. ['bigtext'=>['font-size'=>'4rem']].
Generate a style="..." attribute with the proper inline CSS declarations previously declared with <declare_inline_css>.
Name or names of the rules to apply.
Returns the inline CSS if true, or echo the style attribute if true (default).
Returns standard CSS units.
Echo an image size attribute.
Original width of the image.
Original height of the image. If null, the image will be considerated as a square of $w x $w.
Optional scale to apply on se size (default 1).
Returns icon string, with the format given by cfg('@output.icons.format'), or a fallback.
Icon name.
Icon format.
Echo icon string, generated with <icon()>.
Icon name.
Icon format.
Display a JSON string.
Data to encode.
HTTP Code.
Prettify JSON string or not.
Echo a \n after the JSON. Nicer for terminal display.
Display a JSON string, with a property 'success' set to true.
Optional data to encode.
HTTP Code.
Prettify JSON string or not.
Display a JSON string, with a property 'success' set to false, and an 'error' code/message.
Error added in the output JSON object.
Optional data to encode.
HTTP Code.
Prettify JSON string or not.
Display a JSON error "unauthorized" with an optional message.
Error message.
Display a JSON error "not_found" with an optional message.
Error message.
Display a JSON error "internal_error" with an optional message.
Error message.
Redirect the user with a HTTP header 'Location'. The URL will be processed through <url> with the optional $vars.
Location URL.
Optional URL query strings.
HTTP code (default 302).
System message to show.
HTML string to display.
Message type for pre-styling. Can be one of: 'info', 'error' or 'success'.
Title, set in a <h1> before the $html.
Plain text to display. If $html and $text are provided, $text will be escaped then append after $html.
HTML text to display at the beginning of the message's code.
Send headers and readfile, to force download to the client.
Path to the file.
Content Type of the file.
File name passed as header. If null, the basename of the path will be used.
Close the app immediatly after reading file?
Force download, or allows to render file inline.
The raw data, in replacement of the path.
Echo the content of an image file, with the proper headers.
Path to the image file.
Content type. If null, the function will try to get the proper mime type.
Exit the current code whithout a 404 error.
Register a callback function which will be called after trying every route, without success.
Function called just before throwing a 404.
Call the optionnaly registered fallback function. If this function returns a true, the 404 will not be thrown directly.
Register a callback function which will be called before any route. This can be usefull, for example, to setup, from a helper or directly inside the index.php, a function which will be able to fill the global template variables.
Function which will be called before executing a route.
Register a global modifier for URLs building.
Closure called on each URL building. The unique and first parameter is the URL which is currently processed. The function must returns the URL, modified or not.
Returns the registered URLs modifiers.
Apply registered URL modifiers on a given path.
Path to process.
Register a route filter. When a route will match with the current URL, the registered filters callbacks will be runned. If one of them returns false, the route will not be reached and the next one will be tried. The route filters are cleared automatically at the beginning of each controller files. The classic purpose of this behaviour is to apply all the routes of a controller file only on specific domain name, or only if there is a cookie registered, or only with some IP addresses.
Filter callback. A function which will take one argument: the Microbe class instance, in which are available GET/POST parameters, route arguments and the route path (aka the path given as first argument of <route>).
Shortcut to <register_route_filter>, to register a route filter which will check if the current domain name corresponds to the given pattern. If the pattern seems to be a regex (begins and ends with slashes), a regex comparisition will be done. Else, a strictly equal comparisition will be used.
Domain name or regex to validate the current domain.
Clear the registered route filters. This function is always called immediately before requiring a controller file.
Returns the registered route filters.
Set route arguments, prepended to route functions.
Array of objects with 'name' and 'func' properties.
Returns predefined route arguments.
Add a route argument. A route argument is defined by its name (for further deletion purpose), and its callback function. The function should return the value which will be given as the route's function argument.
Name of predefined argument.
Function executed to get the proper value.
Delete a specific route argument.
Name of the argument
Compute predefined route args.
Optional current URL, passed to args functions.
Optional array containing URL arguments.
Add a route rule. The first argument is the path who have to match. The second argument is the callback which will be executed if the URL match. Before executing a route, the route filters registered with <register_route_filter> will be executed. If the $path is an array of paths, the separated routes will be declared for each item of the array. The path parts between chevrons will be considered as jokers, and returned in the Microbe instance. Note the behaviour of the parts between chevrons:
'/foo/<var>' will match '/foo/abc' or '/foo/123', but not '/foo/abc/123';
'/foo/<var>/bar' will match '/foo/abc/bar' or '/foo/abc/123' but not '/foo/abc/def/bar';
'/foo/<*var>' will match '/foo/abc', 'foo/abc/def', 'foo/bar/abc/def/123', etc.
'/foo/<var:bar>' will match '/foo/bar' only, and set the route argument 'var' to 'bar'. It's useful when using a paths array, to differenciate the different paths.
Path of the URL which should match.
Function to call when the route match. This function will accept a Microbe instance as unique parameter.
Generate a URL. The $args argument can be skipped and replaced by the $host argument. Some special paths which can be given as first argument:
'.': current path, with query strings;
'./': current path, without query strings;
':back': HTTP_REFERER if available, or $fallback, or '/';
Path of the URL.
Query String arguments.
Prepend the protocol and the hostname or not.
Back-url fallback. Used with special path ':back'.
Generate a URL using <url()>, then echo it.
Path of the URL.
Query String arguments.
Prepend the protocol and the hostname or not.
Back-url fallback. Used with special path ':back'.
Generate a URL using <url()>, then echo it, escaped.
Path of the URL.
Query String arguments.
Prepend the protocol and the hostname or not.
Back-url fallback. Used with special path ':back'.
Tries to check if the given URL is NOT pointing to the current site.
URL to checj.
Shortcut to the 'hash' sha256 function call.
String to hash.
Hash some string with specified algorithm, but replace 'cd' with 'xd', to avoid issues when using part of the hashed string as a path folder (e.g. abcdef.jpg -> ab/cd/abcdef.jpg).
Algorithm.
String to hash.
Execute <hashed()> with algorithm SHA-256.
String to hash.
Execute <hashed()> with algorithm SHA-1.
String to hash.
Generate a unique hexadecimal UID string of 64 character maximum.
Length of the UID (maximum: 64 character).
Use the <password> function instead of a SHA-256 hash. Note: the returned string will be [a-z0-9] instead of [a-f0-9].
Check if some value is formatted as a UID.
Value to verify.
Expected length (or array of lengths).
Returns special characters list as a string.
Returns random special character.
Generate a pseudo-random password.
Length of the password.
Insert or not one special character.
Use lowercase and uppercase letters.
Generate a numeric password with the request length. Basically, it just runs the <password> function will only numbers in use.
Password length.
Create a syllabic password including numbers and special chars.
Length of the password. Should be odd. If not, it will be forced up.
Generate standard conditions for password security. The conditions are configurable through some @app.secure.passwords... configuration entries.
Check if a given password validate the conditions returned by <get_password_conditions()>.
Password
Shortify a UID to a specified length.
Full UID, or a Microbe_Entity, or a stdClass containing a uid property.
Length to shortify to.
Hash a password, using the configuration settings in the section @security.
Password to hash.
Hash a password, then check if this value corresponds to an entry 'password' of an array, an object or directly to the given string.
Object or array containing a key 'password', or a hashed password string.
Password to hash and compare.
Compute password strength score.
Password to check.
Minimum length (default 6).
Excellent length (default 20).
Performs a global security check and returns an array containing the result of each item of control.
Start the session if it was not already done.
Get a value from the global $_SESSION array.
Name of the session var.
Set some value for a specific session variable (aka global $_SESSION array).
Name of the variable.
Value to set.
Delete a session variable (aka an entry of the global $_SESSION array).
Name of the variable.
Returns all the session flash variables.
Define some flash variables.
Array representing the flash variables.
Replace all the flash variables. If false (default), the given $vars will be merged into the current variables.
Define a flash variable. This value, represented by a name, will be stored in the session until a standard call to <get_flash_var>.
Name of the flash variable.
Value of the variable.
Delete a flash variable.
Name of the flash variable.
Get a flash variable. If the second parameter stays at true, the variable will be deleted. The standard use case of a flash variable should be to be set on a request, then get and cleaned on the next request (e.g. form data/errors, global error message, etc.).
Name of the flash variable.
Get the value, then delete the variable before the return. Default is true.
Push a flash message. Basically, it will get, push then set a flash variable. If the value is empty or null, the message will be
Value to push.
Name of the messages context.
Type of the message. Should be one of the MB_FLASH_MSG_* constants.
Returns the flash messages of the given context name. The result will be an array containing zero or more objects with two properties: the type (corresponding to one of the MB_FLASH_MSG_* constants) and the message as a string. If the second parameter is left as true, the flash messages will be deleted after the getting.
Name of the messages context.
Get the value, then delete the messages before the return. Default is true.
Setup the framework's environment, with specific scope(s).
Setup scope(s): web, or config, tree, samples.
Setup configuration.
Setup tree.
Setup samples.
Fire the event 'register_cfg_snippets' and merge all the results to create the sample configuration file based on those returned arrays, then returns this merging as a JSON string.
Register Sitemap Source.
String to encode.
Function which will be executed to generate the sitemap. This function should returns an array of associative arrays containing keys:
loc (mandatory);
lastmod;
changefreq;
priority.
Priority: lower is the value, higher is the priority and sooner the links will appear in the sitemap.
Returns registered Sitemap Sources.
Returns registered Sitemap Source.
Source name.
Execute Sitemap Sources functions to fetch all links.
Generate Sitemap based on registered Sitemap Sources.
XML Sitemap output path.
Check all existing sitemaps.
Include number of links.
Regular expression used to match expected files.
Directory (based on project root) where the files are expected.
Encode HTML entities in a string.
String to encode.
Echo the encoded HTML using <esc()>.
String to escape.
Decode HTML entities from a string.
String to decode.
Echo the decoded HTML using <unesc()>.
String to decode.
Remove block tags from HTML string.
String to clean.
Check if the string contains only simple characters, excluding special quotes, emojis, etc.
Unicode letters with accents;
Numbers;
Everything else should be simple ASCII.
Probably a string.
Returns given string after replacement of key-value $params.
String to process.
Key-Value array of params to replace.
String defining the format of the keys as specified in input string.
Check if the string seems to be a valid Base64 encoded string.
String to be checked.
Truncate a text word by word.
Text to truncate.
Maximum length of the returned text.
Add an ellipsis if the text was truncated. If null, nothing is appent. If true, the three-dots will be used. Else, the given string will be appent.
Truncate a string without taking count of words.
Text to truncate.
Maximum length of the returned text.
Add an ellipsis if the text was truncated. If null, nothing is appent. If true, the three-dots will be used. Else, the given string will be appent.
Sanitize a string, removing accents and special character, and trimming it.
String to sanitize.
Words separator (replacing all non alpha-numerical character).
Keep a file's extension.
Shorten the string to a maximum length.
Convert some HTML to its pseudo equivalent Plain Text.
Probably some HTML code.
Clean and cast an unknown value to a float number. Returns null if the value is empty or totally invalid.
Input value.
Cast some scalar value to a predefined format. Cast methods availables are:
number
int
percentage
hours
Value to cast.
Cast method.
Format a number.
Value to cast.
Format a number.
Value to cast.
Replace a bucket of strings, based on a Key/Value array. If the key seems to be a regex (aka starting and ending with a /, with optional ending modifiers), a preg_replace will be used instead of a str_replace.
Pattern/Value replacements array.
Input string.
Replace the last occurence of a substring.
Substring to replace.
Substring replacement.
Full string.
Check a string and returns true if it seems to contains standard regex delimiters with optional modifieds.
String which could be a regex.
Convert a string with optional joker stars, to a regex.
Input string.
Enforce a string is in UTF8.
String to validate.
Check a string and returns true if it seems to contains some UTF-8 character.
String to verify.
Remove accents from a UTF-8 or ISO-8859-1 string.
String to process.
Returns a bolded unicode string.
Input string.
Create an almost prononciable word, switching between vowels and consonants.
Minimum number of syllables.
Maximum number of syllables.
Exclude confusing letters or not.
Get a random letter, with optional choice between a vowel or a consonant.
Can be 'vowel', 'consonant' or null for both.
Exclude confusing letters or not.
Create a fake sentence.
Minimum number of words in the sentence.
Maximum number of words in the sentence.
Minimum number of syllables.
Maximum number of syllables.
Put a final dot or not?
Create a paragraph containing some sentences.
Minimum number of sentences.
Maximum number of sentences.
Create some paragraphes, returned as an array or a HTML string.
Minimum number of paragraphes.
Maximum number of paragraphes.
Return as an HTML string or not.
Get some random western's actor name.
Gender (male, female). Default: null = random.
Tries to sanitize and normalize a full name (John Doe).
Name.
Remove useless spaces and comments in some HTML code.
Unminified HTML code.
Beautify an HTML string, using the third-party Beautify_Html class.
Ugly HTML code.
Split a string between values, by default using commas and/or semicolons as separator, then trim and remove empty values.
Some string with optional .
Separator, as a regex or a simple substring.
Increment a string, using a validation function.
Base string.
Prefix where {idx} is replaced by increment.
Suffix where {idx} is replaced by increment.
Validation function, taking two arguments: the incremented string, and the index as integer.
Explode the strings part, based on conventional case separators: camel-cased, dashes or underscores.
Input string.
If given, this string will be used for an implode and a string will be returned instead of an array.
Returns a camelCasedString.
Input string.
Returns a PascalCasedString.
Input string.
Returns a snake_cased_string, a SNAKE_CASED_STRING or a Snake_Cased_String.
Input string.
Uppercase all the string.
Uppercase the first letter of each word.
Returns a kebab-cased-string, or a KEBAB-CASED-STRING.
Input string.
Uppercase all the string.
Extract quoted substrings from a string, and returns an object with the original string altered with unquoted $replacement, and the quotes as an array of objects containing the initial quoted text.
Input string
Replacement string, with a %d somewhere which will be replaced by the quote index.
Quotes taken in account (default "').
Parse a query which can have some words, and key/value pairs. E.g.: foo bar id:123
Query terms.
Guess the location fo the PHP binary, ideally including the same PHP version.
Fallback PHP binary path.
Execute a PHP file using current PHP binary.
Path of PHP file to execute.
Variables to pass as environment variables got in child via ($_SERVER).
Return execution response instead of echoing it.
Path of PHP binary. Default is guessed from PHP_BINARY.
Execute an interactive command through <proc_open>, and wait for some of the entries of $expect, then answer it.
Command to execute.
Simple array, containing associative arrays with the following enties:
<in>, as a regex tested on each text row returned by the command.
<out>, as the string to write in the <stdout>, as an input to the command.
An optional regex which indicates that we can consider the program is fully exectuted, so we don't have to wait the timeout of <stream_select>.
Echo each result of the stream. Default false.
Returns the user or group name, from its system ID.
System user/group ID
Returns the current's process user ID.
Returns the current's process user name.
Name of the task.
Function executed when the task is called. This function takes two arguments:
string $ctx: The context ('web' or 'cli').
object $args: An object containing arguments passed as command line parameter or query string.
Arguments description, taking associative arrays with the following keys: string 'desc' and bool 'optional'.
Task is enabled on web context.
Task is enabled on cli context.
Assert if the standalone files for each task are created, and delete useless tasks files.
Registered tasks. If null, tasks will be retrieved.
Force generation of files even if exists.
Returns registered tasks.
Execute assert_tasks_files() in order to control existence of standalone PHP files which execute the task.
Returns a specific registered task.
UID of the task.
Bundle of the task (associated with $name).
Name of the task (associated with $bundle).
Generate the callable URL for a specific task.
Task UID.
Generate the shell command to execute the task through related CLI action.
Task UID.
Execute a specific task.
Task name or UID.
Context: 'web' or 'cli'.
Arguments passed to the task (usualy CLI arguments or query-strings).
Returns the <microtime> in microseconds (and not in seconds).
Returns the time since the beginning of the script.
Returns app timezone.
Returns app timezone name.
Returns system timezone.
Returns system timezone name.
Returns all timezones supported by system.
Returns a simple array of strings names instead of detailled info.
Check if the given identifier is a valid timezone.
Probably a timezone name.
Echo the current year.
Convert a number of seconds to hh:mm:ss
Number of seconds.
String returned if $seconds is over a day.
Parse a duration string, suffixed with one of those units: s(econds), m(inutes), h(ours), d(ays), w(eeks), y(ears). Note that there is no monthes unit for two reasons: first, there can be a conflict between minutes and monthes, and secondary, the conversion from month to seconds may vary a lot because of the variability of the month duration, from 28 to 31 days.
Some string suffixed with a time unit.
Returns DateInterval instance instead of an integer of seconds.
Parse a duration string, and create the corresponding PHP DateInterval.
Some string suffixed with a time unit.
Check if a file or a date is expired, based on given time-to-live.
Some date to check. Could be:
DateTimeInterface instance;
UNIX timestamp;
String date, as "Y-m-d H:i:s";
File path (the modified time will be checked).
Time-to-live. Could be:
Seconds as an integer;
DateInterval instance;
The DateInterval duration string (as "P...T...").
Compute the time ago since a specified date and time.
Date and time of the event. Can be a DateTime object, a string which can be parsed by the DateTime constructor, or a timestamp as an integer.
Now DateTime. Default, now.
Don't filter the fields (YMWDhms), so returns all the fields, even if they're zero.
Returns null if the delay is above the given limit, represented as seconds or a string duration.
Returns lowercased.
Returns lowercased.
Text format to be returned.
Execute a reversed <get_time_ago()> with labels adapted for the time remaining between the two dates.
Date and time of the event. Can be a DateTime object, a string which can be parsed by the DateTime constructor, or a timestamp as an integer.
Now DateTime. Default, now.
Don't filter the fields (YMWDhms), so returns all the fields, even if they're zero.
Returns null if the delay is above the given limit, represented as seconds or a string duration.
Returns lowercased.
Returns lowercased.
Returns the month names and numbers as an array containing monthes as objects, with those information:
Index: integer number of the month (1 for january, 12 for december).
$month->num: padded month number.
$month->name: long name translated (e.g. February).
$month->short: short name translated (e.g. Feb).
Locale name.
Get the month name based on its index.
Index of the month ('08' or 8).
Returns the short name if true. Else, the long.
Locale name.
Returns the days of week names and numbers as an array containing days as objects, with those information:
Index: integer number of the day (1 for monday, 7 for sunday).
$day->num: integer day number.
$day->name: long name translated (e.g. Wednesday).
$day->short: short name translated (e.g. Wed).
Locale name.
Get the day name based on its index.
Index of the day ('5' or 5).
Returns the short name if true. Else, the long.
Locale name.
Check if a given value is a proper string representing a PHP date/time.
Value to be checked.
The format, with similar notation as PHP DateTime's format function.
Build a DateTime from two form inputs: YYYY-MM-DD and hh:mm:ss.
Form date which should be YYYY-MM-DD.
Form time which should be hh:mm:ss.
Format the date based on given locale.
Date.
Locale.
Custom IntlDateFormatter pattern, or:
short
medium
long
full
If true, year will be removed. If null, year will be removed if it's different from current year.
Timezone. If null, the one got from $dt's DateTime instance will be used.
Echo the formatted date based on given locale.
Date.
Locale.
Returns an object containing the weeks and days of weeks of a given month, in order to be used to display a calendar.
Requested year.
Requested month.
Is sunday first day of the week. If false (default), then monday is.
Function executed for each day, to populate the "data" property.
URL for previous/current/next monthes information.
Check if a value seems to represent a true or not (e.g, '1', 'yes', etc.).
Value to be checked.
Returns the dump (aka 'var_dump') of a variable.
Variable to dump.
Check if the given object is an object and return its ID property as defined as key parameter, if exists, or null. If the given object is a scalar variable, check if this value is numeric and returns it (assuming it's already the ID). If nothing works, it will returns null.
Object, string or integer thing.
ID key.
Merge several array and/or objects together, like array_merge, but type-tolerant.
Delete unwanted keys in array or object.
Array or object to process.
Allowed keys.
Map an object, exactly like <array_map> does for arrays.
Callback function executed for each item. The first parameter is the item itself. The second is the property name.
Input object.
Convert recursively an array or an object to an array.
Object/array to convert.
Convert recursively an array or an object to an object.
Object/array to convert.
Get the constants defined in a specific class, optionaly altered by a regexp and/or a user function.
Name of the class
Regular expression used for
Alteration function.
Create an array containing object pairs with 'from' and 'to' index values, based on a unidimensional array containing all indexes. E.g. [ 2, 1, 3, 0, 2, 4, 8, 7 ] => [ { from: 0, to: 4 }, { from: 7, 8 } ]
Array of indexes.
Shuffle an associative array, preserving keys.
Check if the given value is an integer, whatever it's inside a string or not.
Value to verify.
Check if the given value is a float, whatever it's inside a string or not.
Value to verify.
Check if the given argument is an associative array, aka an array with non-numerical keys and/or some non-consecutive numerical keys.
Array to verify.
Check if the given argument is an array with perfect consecutive numerical keys or not.
Array to verify.
Filter an array recursively.
Array to filter.
Function to execute on each leave. If the function is null, a boolean comparision will be made.
If true, the array without leaves will be removed. Else, the empty array will stay in place.
Execute a function recursively on items of an array, looking for the children using a specific key.
Array of items.
Key to look for on each item, to find its own children.
Function to execute. This function will accept three parameters:
the given child;
its depth;
its parents.
Current depth. Default starting depth is zero. It's used by the function itself to increment the depth while walking diving inside the array.
Walk through a recursive object and/or array to find the chained key, in which keys are separated by $separator (default '.'). E.g. walk_data([ 'a' => [ 'aa' => 'foo' ] ], 'a/aa', '/') => 'foo'
Recursive object and/or array to walk through.
Chained key.
Keys separator. Default '.'.
Cast a recursive data, using the pattern given as $data. E.g. $casted = cast_data($inputData, (object) [ 'name' => '?str', 'meta' => (object) [ 'categories' => '?str[]', 'url' => '?str', 'timestamp' => '?int', ], ]);
Input value.
Pattern of the data we are waiting for.
Trim string values or not (default true)?
Chained keys separator (when default one may be found in one of the key names).
Current walking key. Internal use only.
Returns the most contrasted color (white or black), based on a specified color.
Hexadecimal color. Hash is optional.
Returns the result as an RGB triplet instead of an hexadecimal color.
Uncompress a ZIP file into a destination folder.
ZIP file path.
Folder where the zip should be unzip.
Compress a folder into a ZIP file.
Folder which should be compressed.
ZIP file destination path.
Filter function.
Boot the application, with the given context:
'web' should be used from 'index.php';
'cli' will be used automatically when calling the framework's file from command line;
'dev' will be used automatically when openning the framework's file directly from the web browser.
Context name