CodeIgniter v4.5 API

Application

Table of Contents

Interfaces

FileLocatorInterface
Allows loading non-class files in a namespaced manner.
CacheInterface
Cache interface
CloneableCookieInterface
Interface for a fresh Cookie instance with selected attribute(s) only changed from the original instance.
CookieInterface
Interface for a value object representation of an HTTP cookie.
ConnectionInterface
ExceptionInterface
Provides a domain-level interface for broad capture of all database-related exceptions.
PreparedQueryInterface
QueryInterface
Interface QueryInterface
ResultInterface
CastInterface
ExceptionHandlerInterface
EncrypterInterface
CodeIgniter Encryption Handler
CastInterface
Interface CastInterface
ExceptionInterface
Provides a domain-level interface for broad capture of all framework-related exceptions.
HasExitCodeInterface
Interface for Exceptions that has exception code as exit code.
HTTPExceptionInterface
Interface for Exceptions that has exception code as HTTP status code.
FilterInterface
Filter interface
FormatterInterface
Formatter interface
UploadedFileInterface
Value object representing a single file uploaded through an HTTP request. Used by the IncomingRequest class to provide files.
MessageInterface
Expected behavior of an HTTP message
OutgoingRequestInterface
Representation of an outgoing, client-side request.
RequestInterface
Representation of an incoming, server-side HTTP request.
ResponsableInterface
ResponseInterface
Representation of an outgoing, server-side response.
ImageHandlerInterface
Expected behavior of an Image handler
HandlerInterface
Expected behavior for a Log handler
PagerInterface
Expected behavior for a Pager
AutoRouterInterface
Expected behavior of a AutoRouter.
RouteCollectionInterface
Interface RouteCollectionInterface
RouterInterface
Expected behavior of a Router.
SecurityInterface
Expected behavior of a Security.
SessionInterface
Expected behavior of a session container used with CodeIgniter.
FabricatorModel
FabricatorModel
ThrottlerInterface
Expected behavior of a Throttler
ValidationInterface
Expected behavior of a validator
RendererInterface
Interface RendererInterface
ViewDecoratorInterface
View Decorators are simple classes that are given the chance to modify the output from the view() calls prior to it being cached.

Classes

Autoloader
An autoloader that uses both PSR4 autoloading, and traditional classmaps.
FileLocator
Allows loading non-class files in a namespaced manner.
FileLocatorCached
FileLocator with Cache
BaseModel
The BaseModel class provides a number of convenient features that makes working with a databases less painful. Extending this class provide means of implementing various database systems
Boot
Bootstrap for the application
CacheFactory
A factory for loading the desired
CacheException
CacheException
FileVarExportHandler
FactoriesCache
BaseHandler
Base class for cache handling
DummyHandler
Dummy cache handler
FileHandler
File system cache handler
MemcachedHandler
Mamcached cache handler
PredisHandler
Predis cache handler
RedisHandler
Redis cache handler
WincacheHandler
Cache handler for WinCache from Microsoft & IIS.
ResponseCache
Web Page Caching
BaseCommand
BaseCommand is the base class used in creating CLI commands.
CLI
Set of static methods useful for CLI request handling.
Commands
Core functionality for running, listing, etc commands.
Console
Console
CLIException
CLIException
InputOutput
Input and Output for CLI.
CodeIgniter
This class is the core of the framework, and will analyse the request, route it to a controller, and send back the response.
ClearCache
Clears current cache.
InfoCache
Shows information on the cache.
CreateDatabase
Creates a new database.
Migrate
Runs all new migrations.
MigrateRefresh
Does a rollback followed by a latest to refresh the current state of the database.
MigrateRollback
Runs all of the migrations in reverse order, until they have all been unapplied.
MigrateStatus
Displays a list of all migrations and whether they've been run or not.
Seed
Runs the specified Seeder file to populate the database with some data.
ShowTableInfo
Get table data if it exists in the database.
GenerateKey
Generates a new encryption key.
CellGenerator
Generates a skeleton Cell and its view.
CommandGenerator
Generates a skeleton command file.
ConfigGenerator
Generates a skeleton config file.
ControllerGenerator
Generates a skeleton controller file.
EntityGenerator
Generates a skeleton Entity file.
FilterGenerator
Generates a skeleton Filter file.
MigrationGenerator
Generates a skeleton migration file.
ModelGenerator
Generates a skeleton Model file.
ScaffoldGenerator
Generates a complete set of scaffold files.
SeederGenerator
Generates a skeleton seeder file.
TestGenerator
Generates a skeleton command file.
ValidationGenerator
Generates a skeleton Validation file.
Help
CI Help command for the spark script.
ClearDebugbar
ClearDebugbar Command
ClearLogs
ClearLogs command.
ListCommands
CI Help command for the spark script.
Serve
Launch the PHP development server
LocalizationFinder
BaseCommand is the base class used in creating CLI commands.
ConfigCheck
Check the Config values.
Environment
Command to display the current environment, or set a new one in the `.env` file.
FilterCheck
Check filters for a route.
Namespaces
Lists namespaces set in Config\Autoload with their full server path. Helps you to verify that you have the namespaces setup correctly.
Optimize
Optimize for production.
PhpIniCheck
Check php.ini values.
Publish
Discovers all Publisher classes from the "Publishers/" directory across namespaces. Executes `publish()` from each instance, parsing each result.
AutoRouteCollector
Collects data for auto route listing.
AutoRouteCollector
Collects data for Auto Routing Improved.
ControllerMethodReader
Reads a controller and returns a list of auto route listing.
ControllerFinder
Finds all controllers in a namespace for auto route listing.
ControllerMethodReader
Reads a controller and returns a list of auto route listing.
FilterCollector
Collects filters for a route.
FilterFinder
Finds filters.
SampleURIGenerator
Generate a sample URI path from route key regex.
Routes
Lists all the routes. This will include any Routes files that can be discovered, and will include routes that are not defined in routes files, but are instead discovered through auto-routing.
AutoloadConfig
AUTOLOADER CONFIGURATION
BaseConfig
Class BaseConfig
BaseService
Services Configuration file.
DotEnv
Environment-specific configuration
Factories
Factories for creating instances.
Factory
Factories Configuration file.
Filters
Filters configuration
ForeignCharacters
Describes foreign characters for transliteration with the text helper.
Publisher
Publisher Configuration
Routing
Routing configuration
Services
Services Configuration file.
View
View configuration
Controller
Class Controller
Cookie
A `Cookie` class represents an immutable HTTP cookie value object.
CookieStore
The CookieStore object represents an immutable collection of `Cookie` value objects.
CookieException
CookieException is thrown for invalid cookies initialization and management.
BaseBuilder
Class BaseBuilder
BaseConnection
BasePreparedQuery
BaseResult
BaseUtils
Class BaseUtils
Config
Class Config
Database
Database Connection Factory
DatabaseException
DataException
Forge
The Forge class transforms migrations to executable SQL statements.
Migration
Class Migration
MigrationRunner
Class MigrationRunner
Builder
Builder for MySQLi
Connection
Connection for MySQLi
Forge
Forge for MySQLi
PreparedQuery
Prepared query for MySQLi
Result
Result for MySQLi
Utils
Utils for MySQLi
Builder
Builder for OCI8
Connection
Connection for OCI8
Forge
Forge for OCI8
PreparedQuery
Prepared query for OCI8
Result
Result for OCI8
Utils
Utils for OCI8
Builder
Builder for Postgre
Connection
Connection for Postgre
Forge
Forge for Postgre
PreparedQuery
Prepared query for Postgre
Result
Result for Postgre
Utils
Utils for Postgre
Query
Query builder
RawSql
Seeder
Class Seeder
Builder
Builder for SQLite3
Connection
Connection for SQLite3
Forge
Forge for SQLite3
PreparedQuery
Prepared query for SQLite3
Result
Result for SQLite3
Table
Class Table
Utils
Utils for SQLite3
Builder
Builder for SQLSRV
Connection
Connection for SQLSRV
Forge
Forge for SQLSRV
PreparedQuery
Prepared query for Postgre
Result
Result for SQLSRV
Utils
Utils for SQLSRV
ArrayCast
Class ArrayCast
BaseCast
BooleanCast
Class BooleanCast
CSVCast
Class CSVCast
DatetimeCast
Class DatetimeCast
FloatCast
Class FloatCast
IntBoolCast
Int Bool Cast
IntegerCast
Class IntegerCast
JsonCast
Class JsonCast
TimestampCast
Class TimestampCast
URICast
Class URICast
DataCaster
CastException
CastException is thrown for invalid cast initialization and management.
DataConverter
PHP data <==> DataSource data converter
BaseExceptionHandler
Provides common functions for exception handlers, especially around displaying the output.
ExceptionHandler
Provides common functions for exception handlers, especially around displaying the output.
Exceptions
Exceptions manager
Iterator
Iterator for debugging.
Timer
Class Timer
BaseCollector
Base Toolbar collector
Config
Debug toolbar configuration
Database
Collector for the Database tab of the Debug Toolbar.
Events
Events collector
Files
Files collector
History
History collector
Logs
Loags collector
Routes
Routes collector
Timers
Timers collector
Views
Views collector
Toolbar
Displays a toolbar with bits of stats to aid a developer in debugging.
Email
CodeIgniter Email Class
Encryption
CodeIgniter Encryption Manager
EncryptionException
Encryption exception
BaseHandler
Base class for encryption handling
OpenSSLHandler
Encryption handling for OpenSSL library
SodiumHandler
SodiumHandler uses libsodium in encryption.
ArrayCast
Class ArrayCast
BaseCast
Class BaseCast
BooleanCast
Class BooleanCast
CSVCast
Class CSVCast
DatetimeCast
Class DatetimeCast
FloatCast
Class FloatCast
IntBoolCast
Int Bool Cast
IntegerCast
Class IntegerCast
JsonCast
Class JsonCast
ObjectCast
Class ObjectCast
StringCast
Class StringCast
TimestampCast
Class TimestampCast
URICast
Class URICast
Entity
Entity encapsulation, for use with CodeIgniter\Model
CastException
CastException is thrown for invalid cast initialization and management.
Events
Events
ConfigException
Exception for automatic logging.
CriticalError
Error: Critical conditions, like component unavailable, etc.
DownloadException
Class DownloadException
FrameworkException
Class FrameworkException
ModelException
Model Exceptions.
PageNotFoundException
TestException
Exception for automatic logging.
FileException
FileNotFoundException
File
Wrapper for PHP's built-in SplFileInfo, with goodies.
FileCollection
File Collection Class
Cors
CSRF
CSRF filter.
DebugToolbar
Debug toolbar filter
FilterException
FilterException
Filters
Filters
ForceHTTPS
Force HTTPS filter
Honeypot
Honeypot filter
InvalidChars
InvalidChars filter.
PageCache
Page Cache filter
PerformanceMetrics
Performance Metrics filter
SecureHeaders
Add Common Security Headers
FormatException
FormatException
Format
The Format class is a convenient place to create Formatters.
JSONFormatter
JSON data formatter
XMLFormatter
XML data formatter
ArrayHelper
HoneypotException
Exception for automatic logging.
Honeypot
class Honeypot
CLIRequest
Represents a request from the command-line. Provides additional tools to interact with that request since CLI requests are not static like HTTP requests might be.
ContentSecurityPolicy
Provides tools for working with the Content-Security-Policy header to help defeat XSS attacks.
Cors
Cross-Origin Resource Sharing (CORS)
CURLRequest
A lightweight HTTP client for sending synchronous HTTP requests via cURL.
DownloadResponse
HTTP response when a download is requested.
BadRequestException
400 Bad Request
HTTPException
Things that can go wrong with HTTP
RedirectException
RedirectException
FileCollection
Class FileCollection
UploadedFile
Value object representing a single file uploaded through an HTTP request. Used by the IncomingRequest class to provide files.
Header
Class Header
IncomingRequest
Class IncomingRequest
Message
An HTTP message
Method
HTTP Method List
Negotiate
Class Negotiate
OutgoingRequest
Representation of an outgoing, client-side request.
RedirectResponse
Handle a redirect response
Request
Representation of an incoming, server-side HTTP request.
Response
Representation of an outgoing, server-side response.
SiteURI
URI for the application site
SiteURIFactory
Creates SiteURI using superglobals.
URI
Abstraction for a uniform resource identifier (URI).
UserAgent
Abstraction for an HTTP user agent
I18nException
I18nException
Time
A localized date/time package inspired by Nesbot/Carbon and CakePHP/Chronos.
TimeDifference
Class TimeDifference
TimeLegacy
Legacy Time class.
ImageException
Class FrameworkException
BaseHandler
Base image handling implementation
GDHandler
Image handler for GD package
ImageMagickHandler
Class ImageMagickHandler
Image
Encapsulation of an Image file
Language
Handle system messages and localization.
LogException
Class FrameworkException
BaseHandler
Base class for logging
ChromeLoggerHandler
Class ChromeLoggerHandler
ErrorlogHandler
Log handler that writes to PHP's `error_log()`
FileHandler
Log error messages to file system
Logger
The CodeIgntier Logger
Model
The Model class extends BaseModel and provides additional convenient features that makes working with a SQL database table less painful.
Modules
Modules Class
PagerException
Class FrameworkException
Pager
Class Pager
PagerRenderer
Class PagerRenderer
ContentReplacer
Replace Text Content
PublisherException
Publisher Exception Class
Publisher
Publishers read in file paths from a variety of sources and copy the files out to different destinations. This class acts both as a base for individual publication directives as well as the mode of discovery for said instances. In this class a "file" is a full path to a verified file while a "path" is relative to its source or destination and may indicate either a file or directory of unconfirmed existence.
BaseResource
Class Controller
ResourceController
An extendable controller to provide a RESTful API for a resource.
ResourcePresenter
An extendable controller to help provide a UI for a resource.
AutoRouter
Router for Auto-Routing
AutoRouterImproved
New Secure Router for Auto-Routing
DefinedRouteCollector
Collect all defined routes for display.
RedirectException
RedirectException
RouterException
RouterException
RouteCollection
Router
Request router.
CheckPhpIni
Checks php.ini settings
SecurityException
Class FrameworkException
Security
Class Security
SessionException
Class FrameworkException
ArrayHandler
Session handler using static array for storage.
BaseHandler
Base class for session handling
MySQLiHandler
Session handler for MySQLi
PostgreHandler
Session handler for Postgre
DatabaseHandler
Base database session handler
FileHandler
Session handler using file system for storage
MemcachedHandler
Session handler using Memcache for persistence
RedisHandler
Session handler using Redis for persistence
Session
Implementation of CodeIgniter session container.
CIUnitTestCase
Framework test case for PHPUnit.
SeeInDatabase
DOMParser
Load a response into a DOMDocument for testing assertions based on that
Fabricator
Fabricator
CITestStreamFilter
Used to capture output during unit testing, so that it can be used in assertions.
MockAppConfig
MockAutoload
MockBuilder
Class BaseBuilder
MockCache
Base class for cache handling
MockCLIConfig
MockCodeIgniter
This class is the core of the framework, and will analyse the request, route it to a controller, and send back the response.
MockConnection
MockCURLRequest
Class MockCURLRequest
MockEmail
CodeIgniter Email Class
MockEvents
Events
MockFileLogger
Class MockFileLogger
MockIncomingRequest
Class IncomingRequest
MockInputOutput
Input and Output for CLI.
MockLanguage
Handle system messages and localization.
MockLogger
MockQuery
Query builder
MockResourceController
An extendable controller to provide a RESTful API for a resource.
MockResourcePresenter
An extendable controller to help provide a UI for a resource.
MockResponse
Class MockResponse
MockResult
MockSecurity
Class Security
MockServices
Services Configuration file.
MockSession
Class MockSession
MockTable
HTML Table Generating Class
PhpStreamWrapper
StreamWrapper for php protocol
TestLogger
The CodeIgntier Logger
TestResponse
Consolidated response processing for test results.
Throttler
Class Throttler
Typography
Typography Class
CreditCardRules
Class CreditCardRules
DotArrayFilter
ValidationException
Class FrameworkException
FileRules
File validation rules
FormatRules
Format validation Rules.
Rules
Validation Rules.
CreditCardRules
Class CreditCardRules
FileRules
File validation rules
FormatRules
Format validation Rules.
Rules
Validation Rules.
Validation
Validator
Cell
Class Cell
Cell
Class Cell
ViewException
Class FrameworkException
Filters
View filters
Parser
Class for parsing pseudo-vars
Plugins
View plugins
Table
HTML Table Generating Class
View
Class View

Traits

ResponseTrait
Provides common, more readable, methods to provide consistent HTTP responses under a variety of common situations when working as an API.
GeneratorTrait
GeneratorTrait contains a collection of methods to build the commands that generates a file.
DebugTraceableTrait
This trait provides framework exceptions the ability to pinpoint accurately where the exception was raised rather than instantiated.
MessageTrait
Message Trait Additional methods to make a PSR-7 Message class compliant with the framework's own MessageInterface.
RequestTrait
Request Trait
ResponseTrait
Response Trait
TimeTrait
This trait has properties and methods for Time and TimeLegacy.
ConfigFromArrayTrait
ControllerTestTrait
Controller Test Trait
DatabaseTestTrait
DatabaseTestTrait
FeatureTestTrait
Trait FeatureTestTrait
FilterTestTrait
Filter Test Trait
IniTestTrait
ReflectionHelper
Testing helper.
StreamFilterTrait
ConditionalTrait
PropertiesTrait
Trait PropertiesTrait
ViewDecoratorTrait

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  = realpath(rtrim($paths->writableDirectory, '\\/ ')) . 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 = realpath(rtrim($paths->writableDirectory, '\\/ ')) . 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
string

cache()

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
phpstan-return

($key is null ? CacheInterface : array|bool|float|int|object|string|null)

Return values
array<string|int, mixed>|bool|CacheInterface|float|int|object|string|null

clean_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
string

command()

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|string

config()

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
template

ConfigTemplate of BaseConfig

phpstan-return

($name is class-string<ConfigTemplate> ? ConfigTemplate : object|null)

Return values
ConfigTemplate|null

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
throws
CookieException
Return values
Cookie

cookies()

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
CookieStore

csrf_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
string

csrf_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
string

csrf_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
string

csrf_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
string

csrf_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
string

csp_style_nonce()

Generates a nonce attribute for style tag.

csp_style_nonce() : string
Return values
string

csp_script_nonce()

Generates a nonce attribute for script tag.

csp_script_nonce() : string
Return values
string

db_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
BaseConnection

env()

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|null

esc()

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
phpstan-param

'html'|'js'|'css'|'url'|'attr'|'raw' $context

throws
InvalidArgumentException
Return values
array<string|int, mixed>|string

force_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
see
https://en.wikipedia.org/wiki/HTTP_Strict_Transport_Security
throws
HTTPException
throws
RedirectException

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
see
http://www.hardened-php.net/suhosin/
codeCoverageIgnore

This is too exotic

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:

  1. app/Helpers
  2. {namespace}/Helpers
  3. system/Helpers
Parameters
$filenames : array<string|int, mixed>|string
Tags
throws
FileNotFoundException

is_cli()

Check if PHP was invoked from the command line.

is_cli() : bool
Tags
codeCoverageIgnore

Cannot be tested fully as PHPUnit always run in php-cli

Return values
bool

is_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
see
https://bugs.php.net/bug.php?id=54709
throws
Exception
codeCoverageIgnore

Not practical to test, as travis runs on linux

Return values
bool

is_windows()

Detect if platform is running in Windows.

is_windows([bool|null $mock = null ]) : bool
Parameters
$mock : bool|null = null
Return values
bool

lang()

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>|string

log_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
template

ModelTemplate of Model

phpstan-return

($name is class-string<ModelTemplate> ? ModelTemplate : object|null)

Return values
ModelTemplate|null

old()

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
phpstan-param

false|'attr'|'css'|'html'|'js'|'raw'|'url' $escape

Return values
array<string|int, mixed>|string|null

redirect()

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
RedirectResponse

remove_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
string

request()

Returns the shared Request.

request() : CLIRequest|IncomingRequest
Return values
CLIRequest|IncomingRequest

route_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
phpstan-return

($val is null ? Session : array|bool|float|int|object|string|null)

Return values
array<string|int, mixed>|bool|float|int|object|Session|string|null

service()

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|null

single_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|null

slash_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
string

timer()

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
phpstan-return

($name is null ? Timer : ($callable is (callable(): mixed) ? mixed : Timer))

Return values
mixed|Timer

view()

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
string

view_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
throws
ReflectionException
Return values
string

class_basename()

Get the class "basename" of the given object / class.

class_basename(object|string $class) : string
Parameters
$class : object|string
Tags
codeCoverageIgnore
Return values
string

class_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
codeCoverageIgnore
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
codeCoverageIgnore
Return values
array<string|int, mixed>

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|null

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|null

array_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
bool

array_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(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
see
Response::setCookie()

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
see
IncomingRequest::getCookie()
Return values
array<string|int, mixed>|string|null

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
see
Response::deleteCookie()

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
bool

now()

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
throws
Exception
Return values
int

timezone_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
throws
Exception
Return values
string

directory_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
throws
InvalidArgumentException

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
bool

delete_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
bool

get_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>|null

symbolic_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
string

octal_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
string

same_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_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
string

form_datalist()

Datalist

form_datalist(string $name, string $value, array<string|int, mixed> $options) : string

The element specifies a list of pre-defined options for an element. Users will see a drop-down list of pre-defined options as they input data. The list attribute of the element, must refer to the id attribute of the element.

Parameters
$name : string
$value : string
$options : array<string|int, mixed>
Return values
string

form_fieldset()

Fieldset Tag

form_fieldset([string $legendText = '' ][, array<string|int, mixed> $attributes = [] ]) : string

Used to produce

text. To close fieldset use form_fieldset_close()

Parameters
$legendText : string = ''

The legend text

$attributes : array<string|int, mixed> = []

Additional attributes

Return values
string

form_fieldset_close()

Fieldset Close Tag

form_fieldset_close([string $extra = '' ]) : string
Parameters
$extra : string = ''
Return values
string

form_close()

Form Close Tag

form_close([string $extra = '' ]) : string
Parameters
$extra : string = ''
Return values
string

set_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>|string

set_select()

Set Select

set_select(string $field[, string $value = '' ][, bool $default = false ]) : string

Let's you set the selected value of a