API Documentation
Table of Contents
Namespaces
Constants
- APPPATH = realpath(rtrim($paths->appDirectory, '\/ ')) . DIRECTORY_SEPARATOR
- APPPATH = \realpath(\rtrim($paths->appDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
- ENVIRONMENT = $env
- ENVIRONMENT = env('CI_ENVIRONMENT', 'production')
- ENVIRONMENT = 'testing'
- ROOTPATH = realpath(APPPATH . '../') . DIRECTORY_SEPARATOR
- ROOTPATH = \realpath(\APPPATH . '../') . \DIRECTORY_SEPARATOR
- STDOUT = 'php://output'
- SYSTEMPATH = realpath(rtrim($paths->systemDirectory, '\/ ')) . DIRECTORY_SEPARATOR
- SYSTEMPATH = \realpath(\rtrim($paths->systemDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
- TESTPATH = realpath(rtrim($paths->testsDirectory, '\/ ')) . DIRECTORY_SEPARATOR
- TESTPATH = \realpath(\rtrim($paths->testsDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
- VENDORPATH = dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR
- WRITEPATH = $writePath . DIRECTORY_SEPARATOR
- WRITEPATH = \realpath(\rtrim($paths->writableDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
Functions
- app_timezone() : string
- Returns the timezone the application has been set to display dates in. This might be different than the timezone set at the server level, as you often want to stores dates in UTC and convert them on the fly for the user.
- cache() : array<string|int, mixed>|bool|CacheInterface|float|int|object|string|null
- A convenience method that provides access to the Cache object. If no parameter is provided, will return the object, otherwise, will attempt to return the cached value.
- clean_path() : string
- A convenience method to clean paths for a nicer looking output. Useful for exception handling, error logging, etc.
- command() : false|string
- Runs a single command.
- config() : ConfigTemplate|null
- More simple way of getting config instances from Factories
- cookie() : Cookie
- Simpler way to create a new Cookie instance.
- cookies() : CookieStore
- Fetches the global `CookieStore` instance held by `Response`.
- csrf_token() : string
- Returns the CSRF token name.
- csrf_header() : string
- Returns the CSRF header name.
- csrf_hash() : string
- Returns the current hash value for the CSRF protection.
- csrf_field() : string
- Generates a hidden input field for use within manually generated forms.
- csrf_meta() : string
- Generates a meta tag for use within javascript calls.
- csp_style_nonce() : string
- Generates a nonce attribute for style tag.
- csp_script_nonce() : string
- Generates a nonce attribute for script tag.
- db_connect() : BaseConnection
- Grabs a database connection and returns it to the user.
- env() : bool|string|null
- Allows user to retrieve values from the environment variables that have been set. Especially useful for retrieving values set from the .env file for use in config files.
- esc() : array<string|int, mixed>|string
- Performs simple auto-escaping of data for security reasons.
- force_https() : void
- Used to force a page to be accessed in via HTTPS.
- function_usable() : bool
- Function usable
- helper() : void
- Loads a helper file into memory. Supports namespaced helpers, both in and out of the 'Helpers' directory of a namespaced directory.
- is_cli() : bool
- Check if PHP was invoked from the command line.
- is_really_writable() : bool
- Tests for file writability
- is_windows() : bool
- Detect if platform is running in Windows.
- lang() : array<int, string>|string
- A convenience method to translate a string or array of them and format the result with the intl extension's MessageFormatter.
- log_message() : void
- A convenience/compatibility method for logging events through the Log system.
- model() : ModelTemplate|null
- More simple way of getting model instances from Factories
- old() : array<string|int, mixed>|string|null
- Provides access to "old input" that was set in the session during a redirect()->withInput().
- redirect() : RedirectResponse
- Convenience method that works with the current global $request and $router instances to redirect using named/reverse-routed routes to determine the URL to go to.
- remove_invisible_characters() : string
- Remove Invisible Characters
- request() : CLIRequest|IncomingRequest
- Returns the shared Request.
- response() : ResponseInterface
- Returns the shared Response.
- route_to() : false|string
- Given a route name or controller/method string and any params, will attempt to build the relative URL to the matching route.
- session() : array<string|int, mixed>|bool|float|int|object|Session|string|null
- A convenience method for accessing the session instance, or an item that has been set in the session.
- service() : object|null
- Allows cleaner access to the Services Config file.
- single_service() : object|null
- Always returns a new instance of the class.
- slash_item() : string|null
- Fetch a config file item with slash appended (if not empty)
- stringify_attributes() : string
- Stringify attributes for use in HTML tags.
- timer() : mixed|Timer
- A convenience method for working with the timer.
- view() : string
- Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a convenience method that can be used in Controllers, libraries, and routed closures.
- view_cell() : string
- View cells are used within views to insert HTML chunks that are managed by other classes.
- class_basename() : string
- Get the class "basename" of the given object / class.
- class_uses_recursive() : array<string|int, mixed>
- Returns all traits used by a class, its parent classes and trait of their traits.
- trait_uses_recursive() : array<string|int, mixed>
- Returns all traits used by a trait and its traits.
- dot_array_search() : array<string|int, mixed>|bool|int|object|string|null
- Searches an array through dot syntax. Supports wildcard searches, like foo.*.bar
- array_deep_search() : array<string|int, mixed>|bool|float|int|object|string|null
- Returns the value of an element at a key in an array of uncertain depth.
- array_sort_by_multiple_keys() : bool
- Sorts a multidimensional array by its elements values. The array columns to be used for sorting are passed as an associative array of key names and sorting flags.
- array_flatten_with_dots() : array<string|int, mixed>
- Flatten a multidimensional array using dots as separators.
- array_group_by() : array<string|int, mixed>
- Groups all rows by their index values. Result's depth equals number of indexes
- set_cookie() : void
- Set cookie
- get_cookie() : array<string|int, mixed>|string|null
- Fetch an item from the $_COOKIE array
- delete_cookie() : void
- Delete a cookie
- has_cookie() : bool
- Checks if a cookie exists by name.
- now() : int
- Get "now" time
- timezone_select() : string
- Generates a select field of all available timezones
- directory_map() : array<string|int, mixed>
- Create a Directory Map
- directory_mirror() : void
- Recursively copies the files and directories of the origin directory into the target directory, i.e. "mirror" its contents.
- write_file() : bool
- Write File
- delete_files() : bool
- Delete Files
- get_filenames() : array<string|int, mixed>
- Get Filenames
- get_dir_file_info() : array<string|int, mixed>
- Get Directory File Information
- get_file_info() : array<string|int, mixed>|null
- Get File Info
- symbolic_permissions() : string
- Symbolic Permissions
- octal_permissions() : string
- Octal Permissions
- same_file() : bool
- Checks if two files both exist and have identical hashes
- set_realpath() : string
- Set Realpath
- form_open() : string
- Form Declaration
- form_open_multipart() : string
- Form Declaration - Multipart type
- form_hidden() : string
- Hidden Input Field
- form_input() : string
- Text Input Field. If 'type' is passed in the $type field, it will be used as the input type, for making 'email', 'phone', etc input fields.
- form_password() : string
- Password Field
- form_upload() : string
- Upload Field
- form_textarea() : string
- Textarea field
- form_multiselect() : string
- Multi-select menu
- form_dropdown() : string
- Drop-down Menu
- form_checkbox() : string
- Checkbox Field
- form_radio() : string
- Radio Button
- form_submit() : string
- Submit Button
- form_reset() : string
- Reset Button
- form_button() : string
- Form Button
- form_label() : string
- Form Label Tag
- form_datalist() : string
- Datalist
- form_fieldset() : string
- Fieldset Tag
- form_fieldset_close() : string
- Fieldset Close Tag
- form_close() : string
- Form Close Tag
- set_value() : array<int, string>|string
- Form Value
- set_select() : string
- Set Select
- set_checkbox() : string
- Set Checkbox
- set_radio() : string
- Set Radio
- validation_errors() : array<string, string>
- Returns the validation errors.
- validation_list_errors() : string
- Returns the rendered HTML of the validation errors.
- validation_show_error() : string
- Returns a single error for the specified field in formatted HTML.
- ul() : string
- Unordered List
- ol() : string
- Ordered List
- _list() : string
- Generates the list
- img() : string
- Image
- img_data() : string
- Image (data)
- doctype() : string
- Doctype
- script_tag() : string
- Script
- link_tag() : string
- Link
- video() : string
- Video
- audio() : string
- Audio
- _media() : string
- Generate media based tag
- source() : string
- Source
- track() : string
- Track
- object() : string
- Object
- param() : string
- Param
- embed() : string
- Embed
- _has_protocol() : false|int
- Test the protocol of a URI.
- _space_indent() : string
- Provide space indenting.
- singular() : string
- Singular
- plural() : string
- Plural
- counted() : string
- Counted
- camelize() : string
- Camelize
- pascalize() : string
- Pascalize
- underscore() : string
- Underscore
- decamelize() : string
- Decamelize
- humanize() : string
- Humanize
- is_pluralizable() : bool
- Checks if the given word has a plural version.
- dasherize() : string
- Replaces underscores with dashes in the string.
- ordinal() : string
- Returns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
- ordinalize() : string
- Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
- dd() : int
- dd function
- d() : int
- d function
- trace() : int
- trace function
- number_to_size() : bool|string
- Formats a numbers as bytes, based on size, and adds the appropriate suffix
- number_to_amount() : bool|string
- Converts numbers to a more readable representation when dealing with very large numbers (in the thousands or above), up to the quadrillions, because you won't often deal with numbers larger than that.
- number_to_currency() : string
- format_number() : string
- A general purpose, locale-aware, number_format method.
- number_to_roman() : string|null
- Convert a number to a roman numeral.
- sanitize_filename() : string
- Sanitize a filename to use in a URI.
- strip_image_tags() : string
- Strip Image Tags
- encode_php_tags() : string
- Convert PHP tags to entities
- fake() : array<string|int, mixed>|object
- Creates a single item using Fabricator.
- mock() : object
- Used within our test suite to mock certain system tools.
- word_limiter() : string
- Word Limiter
- character_limiter() : string
- Character Limiter
- ascii_to_entities() : string
- High ASCII to Entities
- entities_to_ascii() : string
- Entities to ASCII
- word_censor() : string
- Word Censoring Function
- highlight_code() : string
- Code Highlighter
- highlight_phrase() : string
- Phrase Highlighter
- convert_accented_characters() : string
- Convert Accented Foreign Characters to ASCII
- word_wrap() : string
- Word Wrap
- ellipsize() : string
- Ellipsize String
- strip_slashes() : array<string|int, mixed>|string
- Strip Slashes
- strip_quotes() : string
- Strip Quotes
- quotes_to_entities() : string
- Quotes to Entities
- reduce_double_slashes() : string
- Reduce Double Slashes
- reduce_multiples() : string
- Reduce Multiples
- random_string() : string
- Create a Random String
- increment_string() : string
- Add's _1 to a string or increment the ending number to allow _2, _3, etc
- alternator() : string
- Alternator
- excerpt() : string
- Excerpt.
- site_url() : string
- Returns a site URL as defined by the App config.
- base_url() : string
- Returns the base URL as defined by the App config.
- current_url() : string|URI
- Returns the current full URL based on the Config\App settings and IncomingRequest.
- previous_url() : string|URI
- Returns the previous URL the current visitor was on. For security reasons we first check in a saved session variable, if it exists, and use that.
- uri_string() : string
- URL String
- index_page() : string
- Index page
- anchor() : string
- Anchor Link
- anchor_popup() : string
- Anchor Link - Pop-up version
- mailto() : string
- Mailto Link
- safe_mailto() : string
- Encoded Mailto Link
- auto_link() : string
- Auto-linker
- prep_url() : string
- Prep URL - Simply adds the http:// or https:// part if no scheme is included.
- url_title() : string
- Create URL Title
- mb_url_title() : string
- Create URL Title that takes into account accented characters
- url_to() : string
- Get the full, absolute URL to a route name or controller method (with additional arguments)
- url_is() : bool
- Determines if current url path contains the given path. It may contain a wildcard (*) which will allow any valid character.
- xml_convert() : string
- Convert Reserved XML characters to Entities
- is_cli() : bool
- Is CLI?
Constants
APPPATH
public
mixed
APPPATH
= realpath(rtrim($paths->appDirectory, '\/ ')) . DIRECTORY_SEPARATOR
APPPATH
public
mixed
APPPATH
= \realpath(\rtrim($paths->appDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
ENVIRONMENT
public
mixed
ENVIRONMENT
= $env
ENVIRONMENT
public
mixed
ENVIRONMENT
= env('CI_ENVIRONMENT', 'production')
ENVIRONMENT
public
mixed
ENVIRONMENT
= 'testing'
ROOTPATH
public
mixed
ROOTPATH
= realpath(APPPATH . '../') . DIRECTORY_SEPARATOR
ROOTPATH
public
mixed
ROOTPATH
= \realpath(\APPPATH . '../') . \DIRECTORY_SEPARATOR
STDOUT
public
mixed
STDOUT
= 'php://output'
SYSTEMPATH
public
mixed
SYSTEMPATH
= realpath(rtrim($paths->systemDirectory, '\/ ')) . DIRECTORY_SEPARATOR
SYSTEMPATH
public
mixed
SYSTEMPATH
= \realpath(\rtrim($paths->systemDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
TESTPATH
public
mixed
TESTPATH
= realpath(rtrim($paths->testsDirectory, '\/ ')) . DIRECTORY_SEPARATOR
TESTPATH
public
mixed
TESTPATH
= \realpath(\rtrim($paths->testsDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
VENDORPATH
public
mixed
VENDORPATH
= dirname(COMPOSER_PATH) . DIRECTORY_SEPARATOR
WRITEPATH
public
mixed
WRITEPATH
= $writePath . DIRECTORY_SEPARATOR
WRITEPATH
public
mixed
WRITEPATH
= \realpath(\rtrim($paths->writableDirectory, '\/ ')) . \DIRECTORY_SEPARATOR
Functions
app_timezone()
Returns the timezone the application has been set to display dates in. This might be different than the timezone set at the server level, as you often want to stores dates in UTC and convert them on the fly for the user.
app_timezone() : string
Return values
stringcache()
A convenience method that provides access to the Cache object. If no parameter is provided, will return the object, otherwise, will attempt to return the cached value.
cache([string|null $key = null ]) : array<string|int, mixed>|bool|CacheInterface|float|int|object|string|null
Examples: cache()->save('foo', 'bar'); $foo = cache('bar');
Parameters
- $key : string|null = null
Tags
Return values
array<string|int, mixed>|bool|CacheInterface|float|int|object|string|nullclean_path()
A convenience method to clean paths for a nicer looking output. Useful for exception handling, error logging, etc.
clean_path(string $path) : string
Parameters
- $path : string
Return values
stringcommand()
Runs a single command.
command(string $command) : false|string
Input expected in a single string as would be used on the command line itself:
command('migrate:create SomeMigration');
Parameters
- $command : string
Return values
false|stringconfig()
More simple way of getting config instances from Factories
config(ConfigTemplate>|string $name[, bool $getShared = true ]) : ConfigTemplate|null
Parameters
- $name : ConfigTemplate>|string
- $getShared : bool = true
Tags
Return values
ConfigTemplate|nullcookie()
Simpler way to create a new Cookie instance.
cookie(string $name[, string $value = '' ][, array<string|int, mixed> $options = [] ]) : Cookie
Parameters
- $name : string
-
Name of the cookie
- $value : string = ''
-
Value of the cookie
- $options : array<string|int, mixed> = []
-
Array of options to be passed to the cookie
Tags
Return values
Cookiecookies()
Fetches the global `CookieStore` instance held by `Response`.
cookies([array<int, Cookie> $cookies = [] ][, bool $getGlobal = true ]) : CookieStore
Parameters
- $cookies : array<int, Cookie> = []
-
If
getGlobal
is false, this is passed to CookieStore's constructor - $getGlobal : bool = true
-
If false, creates a new instance of CookieStore
Return values
CookieStorecsrf_token()
Returns the CSRF token name.
csrf_token() : string
Can be used in Views when building hidden inputs manually, or used in javascript vars when using APIs.
Return values
stringcsrf_header()
Returns the CSRF header name.
csrf_header() : string
Can be used in Views by adding it to the meta tag or used in javascript to define a header name when using APIs.
Return values
stringcsrf_hash()
Returns the current hash value for the CSRF protection.
csrf_hash() : string
Can be used in Views when building hidden inputs manually, or used in javascript vars for API usage.
Return values
stringcsrf_field()
Generates a hidden input field for use within manually generated forms.
csrf_field([non-empty-string|null $id = null ]) : string
Parameters
- $id : non-empty-string|null = null
Return values
stringcsrf_meta()
Generates a meta tag for use within javascript calls.
csrf_meta([non-empty-string|null $id = null ]) : string
Parameters
- $id : non-empty-string|null = null
Return values
stringcsp_style_nonce()
Generates a nonce attribute for style tag.
csp_style_nonce() : string
Return values
stringcsp_script_nonce()
Generates a nonce attribute for script tag.
csp_script_nonce() : string
Return values
stringdb_connect()
Grabs a database connection and returns it to the user.
db_connect([array<string|int, mixed>|ConnectionInterface|string|null $db = null ][, bool $getShared = true ]) : BaseConnection
This is a convenience wrapper for \Config\Database::connect() and supports the same parameters. Namely:
When passing in $db, you may pass any of the following to connect:
- group name
- existing connection instance
- array of database configuration values
If $getShared === false then a new connection instance will be provided, otherwise it will all calls will return the same instance.
Parameters
- $db : array<string|int, mixed>|ConnectionInterface|string|null = null
- $getShared : bool = true
Return values
BaseConnectionenv()
Allows user to retrieve values from the environment variables that have been set. Especially useful for retrieving values set from the .env file for use in config files.
env(string $key[, string|null $default = null ]) : bool|string|null
Parameters
- $key : string
- $default : string|null = null
Return values
bool|string|nullesc()
Performs simple auto-escaping of data for security reasons.
esc(array<string|int, mixed>|string $data[, string $context = 'html' ][, string|null $encoding = null ]) : array<string|int, mixed>|string
Might consider making this more complex at a later date.
If $data is a string, then it simply escapes and returns it. If $data is an array, then it loops over it, escaping each 'value' of the key/value pairs.
Parameters
- $data : array<string|int, mixed>|string
- $context : string = 'html'
- $encoding : string|null = null
-
Current encoding for escaping. If not UTF-8, we convert strings from this encoding pre-escaping and back to this encoding post-escaping.
Tags
Return values
array<string|int, mixed>|stringforce_https()
Used to force a page to be accessed in via HTTPS.
force_https([int $duration = 31536000 ][, RequestInterface|null $request = null ][, ResponseInterface|null $response = null ]) : void
Uses a standard redirect, plus will set the HSTS header for modern browsers that support, which gives best protection against man-in-the-middle attacks.
Parameters
- $duration : int = 31536000
-
How long should the SSL header be set for? (in seconds) Defaults to 1 year.
- $request : RequestInterface|null = null
- $response : ResponseInterface|null = null
Tags
function_usable()
Function usable
function_usable(string $functionName) : bool
Executes a function_exists() check, and if the Suhosin PHP extension is loaded - checks whether the function that is checked might be disabled in there as well.
This is useful as function_exists() will return FALSE for functions disabled via the disable_functions php.ini setting, but not for suhosin.executor.func.blacklist and suhosin.executor.disable_eval. These settings will just terminate script execution if a disabled function is executed.
The above described behavior turned out to be a bug in Suhosin, but even though a fix was committed for 0.9.34 on 2012-02-12, that version is yet to be released. This function will therefore be just temporary, but would probably be kept for a few years.
Parameters
- $functionName : string
-
Function to check for
Tags
Return values
bool —TRUE if the function exists and is safe to call, FALSE otherwise.
helper()
Loads a helper file into memory. Supports namespaced helpers, both in and out of the 'Helpers' directory of a namespaced directory.
helper(array<string|int, mixed>|string $filenames) : void
Will load ALL helpers of the matching name, in the following order:
- app/Helpers
- {namespace}/Helpers
- system/Helpers
Parameters
- $filenames : array<string|int, mixed>|string
Tags
is_cli()
Check if PHP was invoked from the command line.
is_cli() : bool
Tags
Return values
boolis_really_writable()
Tests for file writability
is_really_writable(string $file) : bool
is_writable() returns TRUE on Windows servers when you really can't write to the file, based on the read-only attribute. is_writable() is also unreliable on Unix servers if safe_mode is on.
Parameters
- $file : string
Tags
Return values
boolis_windows()
Detect if platform is running in Windows.
is_windows([bool|null $mock = null ]) : bool
Parameters
- $mock : bool|null = null
Return values
boollang()
A convenience method to translate a string or array of them and format the result with the intl extension's MessageFormatter.
lang(string $line[, array<string|int, mixed> $args = [] ][, string|null $locale = null ]) : array<int, string>|string
Parameters
- $line : string
- $args : array<string|int, mixed> = []
- $locale : string|null = null
Return values
array<int, string>|stringlog_message()
A convenience/compatibility method for logging events through the Log system.
log_message(string $level, string $message[, array<string|int, mixed> $context = [] ]) : void
Allowed log levels are:
- emergency
- alert
- critical
- error
- warning
- notice
- info
- debug
Parameters
- $level : string
- $message : string
- $context : array<string|int, mixed> = []
model()
More simple way of getting model instances from Factories
model(ModelTemplate>|string $name[, bool $getShared = true ][, ConnectionInterface|null &$conn = null ]) : ModelTemplate|null
Parameters
- $name : ModelTemplate>|string
- $getShared : bool = true
- $conn : ConnectionInterface|null = null
Tags
Return values
ModelTemplate|nullold()
Provides access to "old input" that was set in the session during a redirect()->withInput().
old(string $key[, string|null $default = null ][, false|string $escape = 'html' ]) : array<string|int, mixed>|string|null
Parameters
- $key : string
- $default : string|null = null
- $escape : false|string = 'html'
Tags
Return values
array<string|int, mixed>|string|nullredirect()
Convenience method that works with the current global $request and $router instances to redirect using named/reverse-routed routes to determine the URL to go to.
redirect([non-empty-string|null $route = null ]) : RedirectResponse
If more control is needed, you must use $response->redirect explicitly.
Parameters
- $route : non-empty-string|null = null
-
Route name or Controller::method
Return values
RedirectResponseremove_invisible_characters()
Remove Invisible Characters
remove_invisible_characters(string $str[, bool $urlEncoded = true ]) : string
This prevents sandwiching null characters between ascii characters, like Java\0script.
Parameters
- $str : string
- $urlEncoded : bool = true
Return values
stringrequest()
Returns the shared Request.
request() : CLIRequest|IncomingRequest
Return values
CLIRequest|IncomingRequestresponse()
Returns the shared Response.
response() : ResponseInterface
Return values
ResponseInterfaceroute_to()
Given a route name or controller/method string and any params, will attempt to build the relative URL to the matching route.
route_to(string $method, int|string ...$params) : false|string
NOTE: This requires the controller/method to have a route defined in the routes Config file.
Parameters
- $method : string
-
Route name or Controller::method
- $params : int|string
-
One or more parameters to be passed to the route. The last parameter allows you to set the locale.
Return values
false|string —The route (URI path relative to baseURL) or false if not found.
session()
A convenience method for accessing the session instance, or an item that has been set in the session.
session([string|null $val = null ]) : array<string|int, mixed>|bool|float|int|object|Session|string|null
Examples: session()->set('foo', 'bar'); $foo = session('bar');
Parameters
- $val : string|null = null
Tags
Return values
array<string|int, mixed>|bool|float|int|object|Session|string|nullservice()
Allows cleaner access to the Services Config file.
service(string $name, array<string|int, mixed>|bool|float|int|object|string|null ...$params) : object|null
Always returns a SHARED instance of the class, so calling the function multiple times should always return the same instance.
These are equal:
- $timer = service('timer')
- $timer = \CodeIgniter\Config\Services::timer();
Parameters
- $name : string
- $params : array<string|int, mixed>|bool|float|int|object|string|null
Return values
object|nullsingle_service()
Always returns a new instance of the class.
single_service(string $name, array<string|int, mixed>|bool|float|int|object|string|null ...$params) : object|null
Parameters
- $name : string
- $params : array<string|int, mixed>|bool|float|int|object|string|null
Return values
object|nullslash_item()
Fetch a config file item with slash appended (if not empty)
slash_item(string $item) : string|null
Parameters
- $item : string
-
Config item name
Return values
string|null —The configuration item or NULL if the item doesn't exist
stringify_attributes()
Stringify attributes for use in HTML tags.
stringify_attributes(array<string|int, mixed>|object|string $attributes[, bool $js = false ]) : string
Helper function used to convert a string, array, or object of attributes to a string.
Parameters
- $attributes : array<string|int, mixed>|object|string
-
string, array, object that can be cast to array
- $js : bool = false
Return values
stringtimer()
A convenience method for working with the timer.
timer([non-empty-string|null $name = null ][, callable(): mixed|null $callable = null ]) : mixed|Timer
If no parameter is passed, it will return the timer instance. If callable is passed, it measures time of callable and returns its return value if any. Otherwise will start or stop the timer intelligently.
Parameters
- $name : non-empty-string|null = null
- $callable : callable(): mixed|null = null
Tags
Return values
mixed|Timerview()
Grabs the current RendererInterface-compatible class and tells it to render the specified view. Simply provides a convenience method that can be used in Controllers, libraries, and routed closures.
view(string $name[, array<string|int, mixed> $data = [] ][, array<string|int, mixed> $options = [] ]) : string
NOTE: Does not provide any escaping of the data, so that must all be handled manually by the developer.
Parameters
- $name : string
- $data : array<string|int, mixed> = []
- $options : array<string|int, mixed> = []
-
Options for saveData or third-party extensions.
Return values
stringview_cell()
View cells are used within views to insert HTML chunks that are managed by other classes.
view_cell(string $library[, array<string|int, mixed>|string|null $params = null ][, int $ttl = 0 ][, string|null $cacheName = null ]) : string
Parameters
- $library : string
- $params : array<string|int, mixed>|string|null = null
- $ttl : int = 0
- $cacheName : string|null = null
Tags
Return values
stringclass_basename()
Get the class "basename" of the given object / class.
class_basename(object|string $class) : string
Parameters
- $class : object|string
Tags
Return values
stringclass_uses_recursive()
Returns all traits used by a class, its parent classes and trait of their traits.
class_uses_recursive(object|string $class) : array<string|int, mixed>
Parameters
- $class : object|string
Tags
Return values
array<string|int, mixed>trait_uses_recursive()
Returns all traits used by a trait and its traits.
trait_uses_recursive(string $trait) : array<string|int, mixed>
Parameters
- $trait : string
Tags
Return values
array<string|int, mixed>dot_array_search()
Searches an array through dot syntax. Supports wildcard searches, like foo.*.bar
dot_array_search(string $index, array<string|int, mixed> $array) : array<string|int, mixed>|bool|int|object|string|null
Parameters
- $index : string
- $array : array<string|int, mixed>
Return values
array<string|int, mixed>|bool|int|object|string|nullarray_deep_search()
Returns the value of an element at a key in an array of uncertain depth.
array_deep_search(int|string $key, array<string|int, mixed> $array) : array<string|int, mixed>|bool|float|int|object|string|null
Parameters
- $key : int|string
- $array : array<string|int, mixed>
Return values
array<string|int, mixed>|bool|float|int|object|string|nullarray_sort_by_multiple_keys()
Sorts a multidimensional array by its elements values. The array columns to be used for sorting are passed as an associative array of key names and sorting flags.
array_sort_by_multiple_keys(array<string|int, mixed> &$array, array<string|int, mixed> $sortColumns) : bool
Both arrays of objects and arrays of array can be sorted.
Example: array_sort_by_multiple_keys($players, [ 'team.hierarchy' => SORT_ASC, 'position' => SORT_ASC, 'name' => SORT_STRING, ]);
The '.' dot operator in the column name indicates a deeper array or object level. In principle, any number of sublevels could be used, as long as the level and column exist in every array element.
For information on multi-level array sorting, refer to Example #3 here: https://www.php.net/manual/de/function.array-multisort.php
Parameters
- $array : array<string|int, mixed>
-
the reference of the array to be sorted
- $sortColumns : array<string|int, mixed>
-
an associative array of columns to sort after and their sorting flags
Return values
boolarray_flatten_with_dots()
Flatten a multidimensional array using dots as separators.
array_flatten_with_dots(iterable<string|int, mixed> $array[, string $id = '' ]) : array<string|int, mixed>
Parameters
- $array : iterable<string|int, mixed>
-
The multi-dimensional array
- $id : string = ''
-
Something to initially prepend to the flattened keys
Return values
array<string|int, mixed> —The flattened array
array_group_by()
Groups all rows by their index values. Result's depth equals number of indexes
array_group_by(array<string|int, mixed> $array, array<string|int, mixed> $indexes[, bool $includeEmpty = false ]) : array<string|int, mixed>
Parameters
- $array : array<string|int, mixed>
-
Data array (i.e. from query result)
- $indexes : array<string|int, mixed>
-
Indexes to group by. Dot syntax used. Returns $array if empty
- $includeEmpty : bool = false
-
If true, null and '' are also added as valid keys to group
Return values
array<string|int, mixed> —Result array where rows are grouped together by indexes values.
set_cookie()
Set cookie
set_cookie(array<string|int, mixed>|Cookie|string $name[, string $value = '' ][, int $expire = 0 ][, string $domain = '' ][, string $path = '/' ][, string $prefix = '' ][, bool|null $secure = null ][, bool|null $httpOnly = null ][, string|null $sameSite = null ]) : void
Accepts seven parameters, or you can submit an associative array in the first parameter containing all the values.
Parameters
- $name : array<string|int, mixed>|Cookie|string
-
Cookie name / array containing binds / Cookie object
- $value : string = ''
-
The value of the cookie
- $expire : int = 0
-
The number of seconds until expiration
- $domain : string = ''
-
For site-wide cookie. Usually: .yourdomain.com
- $path : string = '/'
-
The cookie path
- $prefix : string = ''
-
The cookie prefix ('': the default prefix)
- $secure : bool|null = null
-
True makes the cookie secure
- $httpOnly : bool|null = null
-
True makes the cookie accessible via http(s) only (no javascript)
- $sameSite : string|null = null
-
The cookie SameSite value
Tags
get_cookie()
Fetch an item from the $_COOKIE array
get_cookie(string $index[, bool $xssClean = false ][, string|null $prefix = '' ]) : array<string|int, mixed>|string|null
Parameters
- $index : string
- $xssClean : bool = false
- $prefix : string|null = ''
-
Cookie name prefix. '': the prefix in Config\Cookie null: no prefix
Tags
Return values
array<string|int, mixed>|string|nulldelete_cookie()
Delete a cookie
delete_cookie(string $name[, string $domain = '' ][, string $path = '/' ][, string $prefix = '' ]) : void
Parameters
- $name : string
- $domain : string = ''
-
the cookie domain. Usually: .yourdomain.com
- $path : string = '/'
-
the cookie path
- $prefix : string = ''
-
the cookie prefix
Tags
has_cookie()
Checks if a cookie exists by name.
has_cookie(string $name[, string|null $value = null ][, string $prefix = '' ]) : bool
Parameters
- $name : string
- $value : string|null = null
- $prefix : string = ''
Return values
boolnow()
Get "now" time
now([non-empty-string|null $timezone = null ]) : int
Returns Time::now()->getTimestamp() based on the timezone parameter or on the app_timezone() setting
Parameters
- $timezone : non-empty-string|null = null
Tags
Return values
inttimezone_select()
Generates a select field of all available timezones
timezone_select([string $class = '' ][, string $default = '' ][, int $what = DateTimeZone::ALL ][, string $country = null ]) : string
Returns a string with the formatted HTML
Parameters
- $class : string = ''
-
Optional class to apply to the select field
- $default : string = ''
-
Default value for initial selection
- $what : int = DateTimeZone::ALL
-
One of the DateTimeZone class constants (for listIdentifiers)
- $country : string = null
-
A two-letter ISO 3166-1 compatible country code (for listIdentifiers)
Tags
Return values
stringdirectory_map()
Create a Directory Map
directory_map(string $sourceDir[, int $directoryDepth = 0 ][, bool $hidden = false ]) : array<string|int, mixed>
Reads the specified directory and builds an array representation of it. Sub-folders contained with the directory will be mapped as well.
Parameters
- $sourceDir : string
-
Path to source
- $directoryDepth : int = 0
-
Depth of directories to traverse (0 = fully recursive, 1 = current dir, etc)
- $hidden : bool = false
-
Whether to show hidden files
Return values
array<string|int, mixed>directory_mirror()
Recursively copies the files and directories of the origin directory into the target directory, i.e. "mirror" its contents.
directory_mirror(string $originDir, string $targetDir[, bool $overwrite = true ]) : void
Parameters
- $originDir : string
- $targetDir : string
- $overwrite : bool = true
-
Whether individual files overwrite on collision
Tags
write_file()
Write File
write_file(string $path, string $data[, string $mode = 'wb' ]) : bool
Writes data to the file specified in the path. Creates a new file if non-existent.
Parameters
- $path : string
-
File path
- $data : string
-
Data to write
- $mode : string = 'wb'
-
fopen() mode (default: 'wb')
Return values
booldelete_files()
Delete Files
delete_files(string $path[, bool $delDir = false ][, bool $htdocs = false ][, bool $hidden = false ]) : bool
Deletes all files contained in the supplied directory path. Files must be writable or owned by the system in order to be deleted. If the second parameter is set to true, any directories contained within the supplied base directory will be nuked as well.
Parameters
- $path : string
-
File path
- $delDir : bool = false
-
Whether to delete any directories found in the path
- $htdocs : bool = false
-
Whether to skip deleting .htaccess and index page files
- $hidden : bool = false
-
Whether to include hidden files (files beginning with a period)
Return values
boolget_filenames()
Get Filenames
get_filenames(string $sourceDir[, bool|null $includePath = false ][, bool $hidden = false ][, bool $includeDir = true ]) : array<string|int, mixed>
Reads the specified directory and builds an array containing the filenames. Any sub-folders contained within the specified path are read as well.
Parameters
- $sourceDir : string
-
Path to source
- $includePath : bool|null = false
-
Whether to include the path as part of the filename; false for no path, null for a relative path, true for full path
- $hidden : bool = false
-
Whether to include hidden files (files beginning with a period)
- $includeDir : bool = true
-
Whether to include directories
Return values
array<string|int, mixed>get_dir_file_info()
Get Directory File Information
get_dir_file_info(string $sourceDir[, bool $topLevelOnly = true ][, bool $recursion = false ]) : array<string|int, mixed>
Reads the specified directory and builds an array containing the filenames, filesize, dates, and permissions
Any sub-folders contained within the specified path are read as well.
Parameters
- $sourceDir : string
-
Path to source
- $topLevelOnly : bool = true
-
Look only at the top level directory specified?
- $recursion : bool = false
-
Internal variable to determine recursion status - do not use in calls
Return values
array<string|int, mixed>get_file_info()
Get File Info
get_file_info(string $file[, array<string|int, mixed>|string $returnedValues = ['name', 'server_path', 'size', 'date'] ]) : array<string|int, mixed>|null
Given a file and path, returns the name, path, size, date modified Second parameter allows you to explicitly declare what information you want returned Options are: name, server_path, size, date, readable, writable, executable, fileperms Returns false if the file cannot be found.
Parameters
- $file : string
-
Path to file
- $returnedValues : array<string|int, mixed>|string = ['name', 'server_path', 'size', 'date']
-
Array or comma separated string of information returned
Return values
array<string|int, mixed>|nullsymbolic_permissions()
Symbolic Permissions
symbolic_permissions(int $perms) : string
Takes a numeric value representing a file's permissions and returns standard symbolic notation representing that value
Parameters
- $perms : int
-
Permissions
Return values
stringoctal_permissions()
Octal Permissions
octal_permissions(int $perms) : string
Takes a numeric value representing a file's permissions and returns a three character string representing the file's octal permissions
Parameters
- $perms : int
-
Permissions
Return values
stringsame_file()
Checks if two files both exist and have identical hashes
same_file(string $file1, string $file2) : bool
Parameters
- $file1 : string
- $file2 : string
Return values
bool —Same or not
set_realpath()
Set Realpath
set_realpath(string $path[, bool $checkExistence = false ]) : string
Parameters
- $path : string
- $checkExistence : bool = false
-
Checks to see if the path exists
Return values
stringform_open()
Form Declaration
form_open([string $action = '' ][, array<string|int, mixed>|string $attributes = [] ][, array<string|int, mixed> $hidden = [] ]) : string
Creates the opening portion of the form.
Parameters
- $action : string = ''
-
the URI segments of the form destination
- $attributes : array<string|int, mixed>|string = []
-
a key/value pair of attributes, or string representation
- $hidden : array<string|int, mixed> = []
-
a key/value pair hidden data
Return values
stringform_open_multipart()
Form Declaration - Multipart type
form_open_multipart([string $action = '' ][, array<string|int, mixed>|string $attributes = [] ][, array<string|int, mixed> $hidden = [] ]) : string
Creates the opening portion of the form, but with "multipart/form-data".
Parameters
- $action : string = ''
-
The URI segments of the form destination
- $attributes : array<string|int, mixed>|string = []
-
A key/value pair of attributes, or the same as a string
- $hidden : array<string|int, mixed> = []
-
A key/value pair hidden data
Return values
stringform_hidden()
Hidden Input Field
form_hidden(array<string|int, mixed>|string $name[, array<string|int, mixed>|string $value = '' ][, bool $recursing = false ]) : string
Generates hidden fields. You can pass a simple key/value string or an associative array with multiple values.
Parameters
- $name : array<string|int, mixed>|string
-
Field name or associative array to create multiple fields
- $value : array<string|int, mixed>|string = ''
-
Field value
- $recursing : bool = false
Return values
stringform_input()
Text Input Field. If 'type' is passed in the $type field, it will be used as the input type, for making 'email', 'phone', etc input fields.
form_input([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ][, string $type = 'text' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
- $type : string = 'text'
Return values
stringform_password()
Password Field
form_password([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Identical to the input function but adds the "password" type
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_upload()
Upload Field
form_upload([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Identical to the input function but adds the "file" type
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_textarea()
Textarea field
form_textarea([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_multiselect()
Multi-select menu
form_multiselect([array<string|int, mixed>|string $name = '' ][, array<string|int, mixed> $options = [] ][, array<string|int, mixed> $selected = [] ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $name : array<string|int, mixed>|string = ''
- $options : array<string|int, mixed> = []
- $selected : array<string|int, mixed> = []
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_dropdown()
Drop-down Menu
form_dropdown([array<string|int, mixed>|string $data = '' ][, array<string|int, mixed>|string $options = [] ][, array<string|int, mixed>|string $selected = [] ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $options : array<string|int, mixed>|string = []
- $selected : array<string|int, mixed>|string = []
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_checkbox()
Checkbox Field
form_checkbox([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, bool $checked = false ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $checked : bool = false
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_radio()
Radio Button
form_radio([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, bool $checked = false ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $checked : bool = false
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_submit()
Submit Button
form_submit([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_reset()
Reset Button
form_reset([array<string|int, mixed>|string $data = '' ][, string $value = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $value : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_button()
Form Button
form_button([array<string|int, mixed>|string $data = '' ][, string $content = '' ][, array<string|int, mixed>|object|string $extra = '' ]) : string
Parameters
- $data : array<string|int, mixed>|string = ''
- $content : string = ''
- $extra : array<string|int, mixed>|object|string = ''
-
string, array, object that can be cast to array
Return values
stringform_label()
Form Label Tag
form_label([string $labelText = '' ][, string $id = '' ][, array<string|int, mixed> $attributes = [] ]) : string
Parameters
- $labelText : string = ''
-
The text to appear onscreen
- $id : string = ''
-
The id the label applies to
- $attributes : array<string|int, mixed> = []
-
Additional attributes
Return values
stringform_datalist()
Datalist
form_datalist(string $name, string $value, array<string|int, mixed> $options) : string
The
Parameters
- $name : string
- $value : string
- $options : array<string|int, mixed>
Return values
stringform_fieldset()
Fieldset Tag
form_fieldset([string $legendText = '' ][, array<string|int, mixed> $attributes = [] ]) : string
Used to produce
Parameters
- $legendText : string = ''
-
The legend text
- $attributes : array<string|int, mixed> = []
-
Additional attributes
Return values
stringform_fieldset_close()
Fieldset Close Tag
form_fieldset_close([string $extra = '' ]) : string
Parameters
- $extra : string = ''
Return values
stringform_close()
Form Close Tag
form_close([string $extra = '' ]) : string
Parameters
- $extra : string = ''
Return values
stringset_value()
Form Value
set_value(string $field[, array<int, string>|string $default = '' ][, bool $htmlEscape = true ]) : array<int, string>|string
Grabs a value from the POST array for the specified field so you can re-populate an input field or textarea
Parameters
- $field : string
-
Field name
- $default : array<int, string>|string = ''
-
Default value
- $htmlEscape : bool = true
-
Whether to escape HTML special characters or not
Return values
array<int, string>|stringset_select()
Set Select
set_select(string $field[, string $value = '' ][, bool $default = false ]) : string
Let's you set the selected value of a
Parameters
- $field : string
- $value : string = ''
- $default : bool = false
Return values
stringset_checkbox()
Set Checkbox
set_checkbox(string $field[, string $value = '' ][, bool $default = false ]) : string
Let's you set the selected value of a checkbox via the value in the POST array.
Parameters
- $field : string
- $value : string = ''
- $default : bool = false
Return values
stringset_radio()
Set Radio
set_radio(string $field[, string $value = '' ][, bool $default = false ]) : string
Let's you set the selected value of a radio field via info in the POST array.
Parameters
- $field : string
- $value : string = ''
- $default : bool = false
Return values
stringvalidation_errors()
Returns the validation errors.
validation_errors() : array<string, string>
First, checks the validation errors that are stored in the session.
To store the errors in the session, you need to use withInput()
with redirect()
.
The returned array should be in the following format: [ 'field1' => 'error message', 'field2' => 'error message', ]
Return values
array<string, string>validation_list_errors()
Returns the rendered HTML of the validation errors.
validation_list_errors([string $template = 'list' ]) : string
See Validation::listErrors()
Parameters
- $template : string = 'list'
Return values
stringvalidation_show_error()
Returns a single error for the specified field in formatted HTML.
validation_show_error(string $field[, string $template = 'single' ]) : string
See Validation::showError()
Parameters
- $field : string
- $template : string = 'single'
Return values
stringul()
Unordered List
ul(array<string|int, mixed> $list[, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an HTML unordered list from a single or multidimensional array.
Parameters
- $list : array<string|int, mixed>
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
Return values
stringol()
Ordered List
ol(array<string|int, mixed> $list[, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an HTML ordered list from a single or multidimensional array.
Parameters
- $list : array<string|int, mixed>
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
Return values
string_list()
Generates the list
_list([string $type = 'ul' ][, array<string|int, mixed> $list = [] ][, array<string|int, mixed>|object|string $attributes = '' ][, int $depth = 0 ]) : string
Generates an HTML ordered list from a single or multidimensional array.
Parameters
- $type : string = 'ul'
- $list : array<string|int, mixed> = []
-
List entries
- $attributes : array<string|int, mixed>|object|string = ''
-
HTML attributes string, array, object
- $depth : int = 0
Return values
stringimg()
Image
img([array<string|int, mixed>|string $src = '' ][, bool $indexPage = false ][, array<string|int, mixed>|object|string $attributes = '' ]) : string
Generates an image element
Parameters
- $src : array<string|int, mixed>|string = ''
-
Image source URI, or array of attributes and values
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path - $attributes : array<string|int, mixed>|object|string = ''
-
Additional HTML attributes
Return values
stringimg_data()
Image (data)
img_data(string $path[, string|null $mime = null ]) : string
Generates a src-ready string from an image using the "data:" protocol
Parameters
- $path : string
-
Image source path
- $mime : string|null = null
-
MIME type to use, or null to guess
Return values
stringdoctype()
Doctype
doctype([string $type = 'html5' ]) : string
Generates a page document type declaration
Examples of valid options: html5, xhtml-11, xhtml-strict, xhtml-trans, xhtml-frame, html4-strict, html4-trans, and html4-frame. All values are saved in the doctypes config file.
Parameters
- $type : string = 'html5'
-
The doctype to be generated
Return values
stringscript_tag()
Script
script_tag([array<string|int, mixed>|string $src = '' ][, bool $indexPage = false ]) : string
Generates link to a JS file
Parameters
- $src : array<string|int, mixed>|string = ''
-
Script source or an array of attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the JS path
Return values
stringlink_tag()
Link
link_tag([array<string, bool|string>|string $href = '' ][, string $rel = 'stylesheet' ][, string $type = 'text/css' ][, string $title = '' ][, string $media = '' ][, bool $indexPage = false ][, string $hreflang = '' ]) : string
Generates link tag
Parameters
- $href : array<string, bool|string>|string = ''
-
Stylesheet href or an array
- $rel : string = 'stylesheet'
- $type : string = 'text/css'
- $title : string = ''
- $media : string = ''
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the CSS path. - $hreflang : string = ''
Return values
stringvideo()
Video
video(array<string|int, mixed>|string $src[, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ][, bool $indexPage = false ]) : string
Generates a video element to embed videos. The video element can contain one or more video sources
Parameters
- $src : array<string|int, mixed>|string
-
Either a source string or an array of sources
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser
- $attributes : string = ''
-
HTML attributes
- $tracks : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
stringaudio()
Audio
audio(array<string|int, mixed>|string $src[, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ][, bool $indexPage = false ]) : string
Generates an audio element to embed sounds
Parameters
- $src : array<string|int, mixed>|string
-
Either a source string or an array of sources
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser.
- $attributes : string = ''
-
HTML attributes
- $tracks : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
string_media()
Generate media based tag
_media(string $name[, array<string|int, mixed> $types = [] ][, string $unsupportedMessage = '' ][, string $attributes = '' ][, array<string|int, mixed> $tracks = [] ]) : string
Parameters
- $name : string
- $types : array<string|int, mixed> = []
- $unsupportedMessage : string = ''
-
The message to display if the media tag is not supported by the browser.
- $attributes : string = ''
- $tracks : array<string|int, mixed> = []
Return values
stringsource()
Source
source(string $src[, string $type = 'unknown' ][, string $attributes = '' ][, bool $indexPage = false ]) : string
Generates a source element that specifies multiple media resources for either audio or video element
Parameters
- $src : string
-
The path of the media resource
- $type : string = 'unknown'
-
The MIME-type of the resource with optional codecs parameters
- $attributes : string = ''
-
HTML attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
stringtrack()
Track
track(string $src, string $kind, string $srcLanguage, string $label) : string
Generates a track element to specify timed tracks. The tracks are formatted in WebVTT format.
Parameters
- $src : string
-
The path of the .VTT file
- $kind : string
-
How the text track is meant to be used
- $srcLanguage : string
-
Language of the track text data
- $label : string
-
A user-readable title of the text track
Return values
stringobject()
Object
object(string $data[, string $type = 'unknown' ][, string $attributes = '' ][, array<string|int, mixed> $params = [] ][, bool $indexPage = false ]) : string
Generates an object element that represents the media as either image or a resource plugin such as audio, video, Java applets, ActiveX, PDF and Flash
Parameters
- $data : string
-
A resource URL
- $type : string = 'unknown'
-
Content-type of the resource
- $attributes : string = ''
-
HTML attributes
- $params : array<string|int, mixed> = []
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the data path
Return values
stringparam()
Param
param(string $name, string $value[, string $type = 'ref' ][, string $attributes = '' ]) : string
Generates a param element that defines parameters for the object element.
Parameters
- $name : string
-
The name of the parameter
- $value : string
-
The value of the parameter
- $type : string = 'ref'
-
The MIME-type
- $attributes : string = ''
-
HTML attributes
Return values
stringembed()
Embed
embed(string $src[, string $type = 'unknown' ][, string $attributes = '' ][, bool $indexPage = false ]) : string
Generates an embed element
Parameters
- $src : string
-
The path of the resource to embed
- $type : string = 'unknown'
-
MIME-type
- $attributes : string = ''
-
HTML attributes
- $indexPage : bool = false
-
Should
Config\App::$indexPage
be added to the source path
Return values
string_has_protocol()
Test the protocol of a URI.
_has_protocol(string $url) : false|int
Parameters
- $url : string
Return values
false|int_space_indent()
Provide space indenting.
_space_indent([int $depth = 2 ]) : string
Parameters
- $depth : int = 2
Return values
stringsingular()
Singular
singular(string $string) : string
Takes a plural word and makes it singular
Parameters
- $string : string
-
Input string
Return values
stringplural()
Plural
plural(string $string) : string
Takes a singular word and makes it plural
Parameters
- $string : string
-
Input string
Return values
stringcounted()
Counted
counted(int $count, string $string) : string
Takes a number and a word to return the plural or not E.g. 0 cats, 1 cat, 2 cats, ...
Parameters
- $count : int
-
Number of items
- $string : string
-
Input string
Return values
stringcamelize()
Camelize
camelize(string $string) : string
Takes multiple words separated by spaces or underscores and converts them to camel case.
Parameters
- $string : string
-
Input string
Return values
stringpascalize()
Pascalize
pascalize(string $string) : string
Takes multiple words separated by spaces or underscores and converts them to Pascal case, which is camel case with an uppercase first letter.
Parameters
- $string : string
-
Input string
Return values
stringunderscore()
Underscore
underscore(string $string) : string
Takes multiple words separated by spaces and underscores them
Parameters
- $string : string
-
Input string
Return values
stringdecamelize()
Decamelize
decamelize(string $string) : string
Takes multiple words separated by camel case and underscores them.
Parameters
- $string : string
-
Input string
Return values
stringhumanize()
Humanize
humanize(string $string[, string $separator = '_' ]) : string
Takes multiple words separated by the separator, camelizes and changes them to spaces
Parameters
- $string : string
-
Input string
- $separator : string = '_'
-
Input separator
Return values
stringis_pluralizable()
Checks if the given word has a plural version.
is_pluralizable(string $word) : bool
Parameters
- $word : string
-
Word to check
Return values
booldasherize()
Replaces underscores with dashes in the string.
dasherize(string $string) : string
Parameters
- $string : string
-
Input string
Return values
stringordinal()
Returns the suffix that should be added to a number to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
ordinal(int $integer) : string
Parameters
- $integer : int
-
The integer to determine the suffix
Return values
stringordinalize()
Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
ordinalize(int $integer) : string
Parameters
- $integer : int
-
The integer to ordinalize
Return values
stringdd()
dd function
dd(array<string|int, mixed> ...$vars) : int
Parameters
- $vars : array<string|int, mixed>
Return values
intd()
d function
d(array<string|int, mixed> ...$vars) : int
Parameters
- $vars : array<string|int, mixed>
Return values
inttrace()
trace function
trace() : int
Return values
intnumber_to_size()
Formats a numbers as bytes, based on size, and adds the appropriate suffix
number_to_size(int|string $num[, int $precision = 1 ][, non-empty-string|null $locale = null ]) : bool|string
Parameters
- $num : int|string
-
Will be cast as int
- $precision : int = 1
- $locale : non-empty-string|null = null
-
[optional]
Return values
bool|stringnumber_to_amount()
Converts numbers to a more readable representation when dealing with very large numbers (in the thousands or above), up to the quadrillions, because you won't often deal with numbers larger than that.
number_to_amount(int|string $num[, int $precision = 0 ][, non-empty-string|null $locale = null ]) : bool|string
It uses the "short form" numbering system as this is most commonly used within most English-speaking countries today.
Parameters
- $num : int|string
-
Will be cast as int
- $precision : int = 0
-
[optional] The optional number of decimal digits to round to.
- $locale : non-empty-string|null = null
-
[optional]
Tags
Return values
bool|stringnumber_to_currency()
number_to_currency(float $num, string $currency[, string|null $locale = null ][, int $fraction = 0 ]) : string
Parameters
- $num : float
- $currency : string
- $locale : string|null = null
- $fraction : int = 0
Return values
stringformat_number()
A general purpose, locale-aware, number_format method.
format_number(float $num[, int $precision = 1 ][, string|null $locale = null ][, array<string|int, mixed> $options = [] ]) : string
Used by all of the functions of the number_helper.
Parameters
- $num : float
- $precision : int = 1
- $locale : string|null = null
- $options : array<string|int, mixed> = []
Return values
stringnumber_to_roman()
Convert a number to a roman numeral.
number_to_roman(int|string $num) : string|null
Parameters
- $num : int|string
-
it will convert to int
Return values
string|nullsanitize_filename()
Sanitize a filename to use in a URI.
sanitize_filename(string $filename) : string
Parameters
- $filename : string
Return values
stringstrip_image_tags()
Strip Image Tags
strip_image_tags(string $str) : string
Parameters
- $str : string
Return values
stringencode_php_tags()
Convert PHP tags to entities
encode_php_tags(string $str) : string
Parameters
- $str : string
Return values
stringfake()
Creates a single item using Fabricator.
fake(Model|object|string $model[, array<string|int, mixed>|null $overrides = null ][, bool $persist = true ]) : array<string|int, mixed>|object
Parameters
- $model : Model|object|string
-
Instance or name of the model
- $overrides : array<string|int, mixed>|null = null
-
Overriding data to pass to Fabricator::setOverrides()
- $persist : bool = true
Return values
array<string|int, mixed>|objectmock()
Used within our test suite to mock certain system tools.
mock(string $className) : object
Parameters
- $className : string
-
Fully qualified class name
Return values
objectword_limiter()
Word Limiter
word_limiter(string $str[, int $limit = 100 ][, string $endChar = '…' ]) : string
Limits a string to X number of words.
Parameters
- $str : string
- $limit : int = 100
- $endChar : string = '…'
-
the end character. Usually an ellipsis
Return values
stringcharacter_limiter()
Character Limiter
character_limiter(string $str[, int $n = 500 ][, string $endChar = '…' ]) : string
Limits the string based on the character count. Preserves complete words so the character count may not be exactly as specified.
Parameters
- $str : string
- $n : int = 500
- $endChar : string = '…'
-
the end character. Usually an ellipsis
Return values
stringascii_to_entities()
High ASCII to Entities
ascii_to_entities(string $str) : string
Converts high ASCII text and MS Word special characters to character entities
Parameters
- $str : string
Return values
stringentities_to_ascii()
Entities to ASCII
entities_to_ascii(string $str[, bool $all = true ]) : string
Converts character entities back to ASCII
Parameters
- $str : string
- $all : bool = true
Return values
stringword_censor()
Word Censoring Function
word_censor(string $str, array<string|int, mixed> $censored[, string $replacement = '' ]) : string
Supply a string and an array of disallowed words and any matched words will be converted to #### or to the replacement word you've submitted.
Parameters
- $str : string
-
the text string
- $censored : array<string|int, mixed>
-
the array of censored words
- $replacement : string = ''
-
the optional replacement value
Return values
stringhighlight_code()
Code Highlighter
highlight_code(string $str) : string
Colorizes code strings
Parameters
- $str : string
-
the text string
Return values
stringhighlight_phrase()
Phrase Highlighter
highlight_phrase(string $str, string $phrase[, string $tagOpen = '<mark>' ][, string $tagClose = '</mark>' ]) : string
Highlights a phrase within a text string
Parameters
- $str : string
-
the text string
- $phrase : string
-
the phrase you'd like to highlight
- $tagOpen : string = '<mark>'
-
the opening tag to precede the phrase with
- $tagClose : string = '</mark>'
-
the closing tag to end the phrase with
Return values
stringconvert_accented_characters()
Convert Accented Foreign Characters to ASCII
convert_accented_characters(string $str) : string
Parameters
- $str : string
-
Input string
Return values
stringword_wrap()
Word Wrap
word_wrap(string $str[, int $charlim = 76 ]) : string
Wraps text at the specified character. Maintains the integrity of words. Anything placed between {unwrap}{/unwrap} will not be word wrapped, nor will URLs.
Parameters
- $str : string
-
the text string
- $charlim : int = 76
-
= 76 the number of characters to wrap at
Return values
stringellipsize()
Ellipsize String
ellipsize(string $str, int $maxLength[, float|int $position = 1 ][, string $ellipsis = '…' ]) : string
This function will strip tags from a string, split it at its max_length and ellipsize
Parameters
- $str : string
-
String to ellipsize
- $maxLength : int
-
Max length of string
- $position : float|int = 1
-
int (1|0) or float, .5, .2, etc for position to split
- $ellipsis : string = '…'
-
ellipsis ; Default '...'
Return values
string —Ellipsized string
strip_slashes()
Strip Slashes
strip_slashes(array<string|int, mixed>|string $str) : array<string|int, mixed>|string
Removes slashes contained in a string or in an array
Parameters
- $str : array<string|int, mixed>|string
-
string or array
Return values
array<string|int, mixed>|string —string or array
strip_quotes()
Strip Quotes
strip_quotes(string $str) : string
Removes single and double quotes from a string
Parameters
- $str : string
Return values
stringquotes_to_entities()
Quotes to Entities
quotes_to_entities(string $str) : string
Converts single and double quotes to entities
Parameters
- $str : string
Return values
stringreduce_double_slashes()
Reduce Double Slashes
reduce_double_slashes(string $str) : string
Converts double slashes in a string to a single slash, except those found in http://
http://www.some-site.com//index.php
becomes:
http://www.some-site.com/index.php
Parameters
- $str : string
Return values
stringreduce_multiples()
Reduce Multiples
reduce_multiples(string $str[, string $character = ',' ][, bool $trim = false ]) : string
Reduces multiple instances of a particular character. Example:
Fred, Bill,, Joe, Jimmy
becomes:
Fred, Bill, Joe, Jimmy
Parameters
- $str : string
- $character : string = ','
-
the character you wish to reduce
- $trim : bool = false
-
TRUE/FALSE - whether to trim the character from the beginning/end
Return values
stringrandom_string()
Create a Random String
The type 'basic', 'md5', and 'sha1' are deprecated. They are not cryptographically secure.
random_string([string $type = 'alnum' ][, int $len = 8 ]) : string
Useful for generating passwords or hashes.
Parameters
- $type : string = 'alnum'
-
Type of random string. basic, alpha, alnum, numeric, nozero, md5, sha1, and crypto
- $len : int = 8
-
Number of characters
Return values
stringincrement_string()
Add's _1 to a string or increment the ending number to allow _2, _3, etc
increment_string(string $str[, string $separator = '_' ][, int $first = 1 ]) : string
Parameters
- $str : string
-
Required
- $separator : string = '_'
-
What should the duplicate number be appended with
- $first : int = 1
-
Which number should be used for the first dupe increment
Return values
stringalternator()
Alternator
alternator(string ...$args) : string
Allows strings to be alternated. See docs...
Parameters
- $args : string
-
(as many parameters as needed)
Return values
stringexcerpt()
Excerpt.
excerpt(string $text[, string $phrase = null ][, int $radius = 100 ][, string $ellipsis = '...' ]) : string
Allows to extract a piece of text surrounding a word or phrase.
Parameters
- $text : string
-
String to search the phrase
- $phrase : string = null
-
Phrase that will be searched for.
- $radius : int = 100
-
The amount of characters returned around the phrase.
- $ellipsis : string = '...'
-
Ending that will be appended
If no $phrase is passed, will generate an excerpt of $radius characters from the beginning of $text.
Return values
stringsite_url()
Returns a site URL as defined by the App config.
site_url([array<string|int, mixed>|string $relativePath = '' ][, string|null $scheme = null ][, App|null $config = null ]) : string
Parameters
- $relativePath : array<string|int, mixed>|string = ''
-
URI string or array of URI segments.
- $scheme : string|null = null
-
URI scheme. E.g., http, ftp. If empty string '' is set, a protocol-relative link is returned.
- $config : App|null = null
-
Alternate configuration to use.
Return values
stringbase_url()
Returns the base URL as defined by the App config.
base_url([array<string|int, mixed>|string $relativePath = '' ][, string|null $scheme = null ]) : string
Base URLs are trimmed site URLs without the index page.
Parameters
- $relativePath : array<string|int, mixed>|string = ''
-
URI string or array of URI segments.
- $scheme : string|null = null
-
URI scheme. E.g., http, ftp. If empty string '' is set, a protocol-relative link is returned.
Return values
stringcurrent_url()
Returns the current full URL based on the Config\App settings and IncomingRequest.
current_url([bool $returnObject = false ][, IncomingRequest|null $request = null ]) : string|URI
Parameters
- $returnObject : bool = false
-
True to return an object instead of a string
- $request : IncomingRequest|null = null
-
A request to use when retrieving the path
Return values
string|URI —When returning string, the query and fragment parts are removed. When returning URI, the query and fragment parts are preserved.
previous_url()
Returns the previous URL the current visitor was on. For security reasons we first check in a saved session variable, if it exists, and use that.
previous_url([bool $returnObject = false ]) : string|URI
If that's not available, however, we'll use a sanitized url from $_SERVER['HTTP_REFERER'] which can be set by the user so is untrusted and not set by certain browsers/servers.
Parameters
- $returnObject : bool = false
Return values
string|URIuri_string()
URL String
uri_string() : string
Returns the path part (relative to baseURL) of the current URL
Return values
stringindex_page()
Index page
index_page([App|null $altConfig = null ]) : string
Returns the "index_page" from your config file
Parameters
- $altConfig : App|null = null
-
Alternate configuration to use
Return values
stringanchor()
Anchor Link
anchor([array<string|int, mixed>|string $uri = '' ][, string $title = '' ][, array<string|int, mixed>|object|string $attributes = '' ][, App|null $altConfig = null ]) : string
Creates an anchor based on the local URL.
Parameters
- $uri : array<string|int, mixed>|string = ''
-
URI string or array of URI segments
- $title : string = ''
-
The link title
- $attributes : array<string|int, mixed>|object|string = ''
-
Any attributes
- $altConfig : App|null = null
-
Alternate configuration to use
Return values
stringanchor_popup()
Anchor Link - Pop-up version
anchor_popup([string $uri = '' ][, string $title = '' ][, array<string|int, mixed>|false|object|string $attributes = false ][, App|null $altConfig = null ]) : string
Creates an anchor based on the local URL. The link opens a new window based on the attributes specified.
Parameters
- $uri : string = ''
-
the URL
- $title : string = ''
-
the link title
- $attributes : array<string|int, mixed>|false|object|string = false
-
any attributes
- $altConfig : App|null = null
-
Alternate configuration to use
Return values
stringmailto()
Mailto Link
mailto(string $email[, string $title = '' ][, array<string|int, mixed>|object|string $attributes = '' ]) : string
Parameters
- $email : string
-
the email address
- $title : string = ''
-
the link title
- $attributes : array<string|int, mixed>|object|string = ''
-
any attributes
Return values
stringsafe_mailto()
Encoded Mailto Link
safe_mailto(string $email[, string $title = '' ][, array<string|int, mixed>|object|string $attributes = '' ]) : string
Create a spam-protected mailto link written in Javascript
Parameters
- $email : string
-
the email address
- $title : string = ''
-
the link title
- $attributes : array<string|int, mixed>|object|string = ''
-
any attributes
Return values
stringauto_link()
Auto-linker
auto_link(string $str[, string $type = 'both' ][, bool $popup = false ]) : string
Automatically links URL and Email addresses. Note: There's a bit of extra code here to deal with URLs or emails that end in a period. We'll strip these off and add them after the link.
Parameters
- $str : string
-
the string
- $type : string = 'both'
-
the type: email, url, or both
- $popup : bool = false
-
whether to create pop-up links
Return values
stringprep_url()
Prep URL - Simply adds the http:// or https:// part if no scheme is included.
prep_url([string $str = '' ][, bool $secure = false ]) : string
Formerly used URI, but that does not play nicely with URIs missing the scheme.
Parameters
- $str : string = ''
-
the URL
- $secure : bool = false
-
set true if you want to force https://
Return values
stringurl_title()
Create URL Title
url_title(string $str[, string $separator = '-' ][, bool $lowercase = false ]) : string
Takes a "title" string as input and creates a human-friendly URL string with a "separator" string as the word separator.
Parameters
- $str : string
-
Input string
- $separator : string = '-'
-
Word separator (usually '-' or '_')
- $lowercase : bool = false
-
Whether to transform the output string to lowercase
Return values
stringmb_url_title()
Create URL Title that takes into account accented characters
mb_url_title(string $str[, string $separator = '-' ][, bool $lowercase = false ]) : string
Takes a "title" string as input and creates a human-friendly URL string with a "separator" string as the word separator.
Parameters
- $str : string
-
Input string
- $separator : string = '-'
-
Word separator (usually '-' or '_')
- $lowercase : bool = false
-
Whether to transform the output string to lowercase
Return values
stringurl_to()
Get the full, absolute URL to a route name or controller method (with additional arguments)
url_to(string $controller, int|string ...$args) : string
NOTE: This requires the controller/method to have a route defined in the routes Config file.
Parameters
- $controller : string
-
Route name or Controller::method
- $args : int|string
-
One or more parameters to be passed to the route. The last parameter allows you to set the locale.
Tags
Return values
stringurl_is()
Determines if current url path contains the given path. It may contain a wildcard (*) which will allow any valid character.
url_is(string $path) : bool
Example: if (url_is('admin*')) ...
Parameters
- $path : string
Return values
boolxml_convert()
Convert Reserved XML characters to Entities
xml_convert(string $str[, bool $protectAll = false ]) : string
Parameters
- $str : string
- $protectAll : bool = false
Return values
stringis_cli()
Is CLI?
is_cli([bool $newReturn = null ]) : bool
Test to see if a request was made from the command line. You can set the return value for testing.
Parameters
- $newReturn : bool = null
-
return value to set