App
extends BaseConfig
in package
Class BaseConfig
Not intended to be used on its own, this class will attempt to automatically populate the child class' properties with values from the environment.
These can be set within the .env file.
Table of Contents
- $appTimezone : string
- -------------------------------------------------------------------------- Application Timezone --------------------------------------------------------------------------
- $baseURL : string
- -------------------------------------------------------------------------- Base Site URL --------------------------------------------------------------------------
- $charset : string
- -------------------------------------------------------------------------- Default Character Set --------------------------------------------------------------------------
- $cookieDomain : string
- -------------------------------------------------------------------------- Cookie Domain --------------------------------------------------------------------------
- $cookieHTTPOnly : bool
- -------------------------------------------------------------------------- Cookie HttpOnly --------------------------------------------------------------------------
- $cookiePath : string
- -------------------------------------------------------------------------- Cookie Path --------------------------------------------------------------------------
- $cookiePrefix : string
- -------------------------------------------------------------------------- Cookie Prefix --------------------------------------------------------------------------
- $cookieSameSite : string
- -------------------------------------------------------------------------- Cookie SameSite --------------------------------------------------------------------------
- $cookieSecure : bool
- -------------------------------------------------------------------------- Cookie Secure --------------------------------------------------------------------------
- $CSPEnabled : bool
- -------------------------------------------------------------------------- Content Security Policy --------------------------------------------------------------------------
- $CSRFCookieName : string
- -------------------------------------------------------------------------- CSRF Cookie Name --------------------------------------------------------------------------
- $CSRFExpire : int
- -------------------------------------------------------------------------- CSRF Expire --------------------------------------------------------------------------
- $CSRFHeaderName : string
- -------------------------------------------------------------------------- CSRF Header Name --------------------------------------------------------------------------
- $CSRFRedirect : bool
- -------------------------------------------------------------------------- CSRF Redirect --------------------------------------------------------------------------
- $CSRFRegenerate : bool
- -------------------------------------------------------------------------- CSRF Regenerate --------------------------------------------------------------------------
- $CSRFSameSite : string
- -------------------------------------------------------------------------- CSRF SameSite --------------------------------------------------------------------------
- $CSRFTokenName : string
- -------------------------------------------------------------------------- CSRF Token Name --------------------------------------------------------------------------
- $defaultLocale : string
- -------------------------------------------------------------------------- Default Locale --------------------------------------------------------------------------
- $forceGlobalSecureRequests : bool
- -------------------------------------------------------------------------- URI PROTOCOL --------------------------------------------------------------------------
- $indexPage : string
- -------------------------------------------------------------------------- Index File --------------------------------------------------------------------------
- $negotiateLocale : bool
- -------------------------------------------------------------------------- Negotiate Locale --------------------------------------------------------------------------
- $proxyIPs : string|array<string|int, string>
- -------------------------------------------------------------------------- Reverse Proxy IPs --------------------------------------------------------------------------
- $registrars : array<string|int, mixed>
- An optional array of classes that will act as Registrars for rapidly setting config class properties.
- $sessionCookieName : string
- -------------------------------------------------------------------------- Session Cookie Name --------------------------------------------------------------------------
- $sessionDriver : string
- -------------------------------------------------------------------------- Session Driver --------------------------------------------------------------------------
- $sessionExpiration : int
- -------------------------------------------------------------------------- Session Expiration --------------------------------------------------------------------------
- $sessionMatchIP : bool
- -------------------------------------------------------------------------- Session Match IP --------------------------------------------------------------------------
- $sessionRegenerateDestroy : bool
- -------------------------------------------------------------------------- Session Regenerate Destroy --------------------------------------------------------------------------
- $sessionSavePath : string
- -------------------------------------------------------------------------- Session Save Path --------------------------------------------------------------------------
- $sessionTimeToUpdate : int
- -------------------------------------------------------------------------- Session Time to Update --------------------------------------------------------------------------
- $supportedLocales : array<string|int, string>
- -------------------------------------------------------------------------- Supported Locales --------------------------------------------------------------------------
- $uriProtocol : string
- -------------------------------------------------------------------------- URI PROTOCOL --------------------------------------------------------------------------
- $didDiscovery : bool
- Has module discovery happened yet?
- $moduleConfig : Modules
- The modules configuration.
- __construct() : mixed
- Will attempt to get environment variables with names that match the properties of the child class.
- getEnvValue() : mixed
- Retrieve an environment-specific configuration setting
- initEnvValue() : mixed
- Initialization an environment-specific configuration setting
- registerProperties() : mixed
- Provides external libraries a simple way to register one or more options into a config file.
Properties
$appTimezone
-------------------------------------------------------------------------- Application Timezone --------------------------------------------------------------------------
public
string
$appTimezone
= 'Europe/Madrid'
The default timezone that will be used in your application to display dates with the date helper, and can be retrieved through app_timezone()
$baseURL
-------------------------------------------------------------------------- Base Site URL --------------------------------------------------------------------------
public
string
$baseURL
= 'http://localhost:8080/'
URL to your CodeIgniter root. Typically this will be your base URL, WITH a trailing slash:
http://example.com/
If this is not set then CodeIgniter will try guess the protocol, domain and path to your installation. However, you should always configure this explicitly and never rely on auto-guessing, especially in production environments.
$charset
-------------------------------------------------------------------------- Default Character Set --------------------------------------------------------------------------
public
string
$charset
= 'UTF-8'
This determines which character set is used by default in various methods that require a character set to be provided.
Tags
$cookieDomain
-------------------------------------------------------------------------- Cookie Domain --------------------------------------------------------------------------
public
string
$cookieDomain
= ''
Set to .your-domain.com
for site-wide cookies.
Tags
$cookieHTTPOnly
-------------------------------------------------------------------------- Cookie HttpOnly --------------------------------------------------------------------------
public
bool
$cookieHTTPOnly
= true
Cookie will only be accessible via HTTP(S) (no JavaScript).
Tags
$cookiePath
-------------------------------------------------------------------------- Cookie Path --------------------------------------------------------------------------
public
string
$cookiePath
= '/'
Typically will be a forward slash.
Tags
$cookiePrefix
-------------------------------------------------------------------------- Cookie Prefix --------------------------------------------------------------------------
public
string
$cookiePrefix
= ''
Set a cookie name prefix if you need to avoid collisions.
Tags
$cookieSameSite
-------------------------------------------------------------------------- Cookie SameSite --------------------------------------------------------------------------
public
string
$cookieSameSite
= 'Lax'
Configure cookie SameSite setting. Allowed values are:
- None
- Lax
- Strict
- ''
Alternatively, you can use the constant names:
-
Cookie::SAMESITE_NONE
-
Cookie::SAMESITE_LAX
-
Cookie::SAMESITE_STRICT
Defaults to Lax
for compatibility with modern browsers. Setting ''
(empty string) means default SameSite attribute set by browsers (Lax
)
will be set on cookies. If set to None
, $cookieSecure
must also be set.
Tags
$cookieSecure
-------------------------------------------------------------------------- Cookie Secure --------------------------------------------------------------------------
public
bool
$cookieSecure
= false
Cookie will only be set if a secure HTTPS connection exists.
Tags
$CSPEnabled
-------------------------------------------------------------------------- Content Security Policy --------------------------------------------------------------------------
public
bool
$CSPEnabled
= false
Enables the Response's Content Secure Policy to restrict the sources that
can be used for images, scripts, CSS files, audio, video, etc. If enabled,
the Response object will populate default values for the policy from the
ContentSecurityPolicy.php
file. Controllers can always add to those
restrictions at run time.
For a better understanding of CSP, see these documents:
Tags
$CSRFCookieName
-------------------------------------------------------------------------- CSRF Cookie Name --------------------------------------------------------------------------
public
string
$CSRFCookieName
= 'csrf_cookie_name'
The cookie name.
Tags
$CSRFExpire
-------------------------------------------------------------------------- CSRF Expire --------------------------------------------------------------------------
public
int
$CSRFExpire
= 7200
The number in seconds the token should expire.
Tags
$CSRFHeaderName
-------------------------------------------------------------------------- CSRF Header Name --------------------------------------------------------------------------
public
string
$CSRFHeaderName
= 'X-CSRF-TOKEN'
The header name.
Tags
$CSRFRedirect
-------------------------------------------------------------------------- CSRF Redirect --------------------------------------------------------------------------
public
bool
$CSRFRedirect
= true
Redirect to previous page with error on failure?
Tags
$CSRFRegenerate
-------------------------------------------------------------------------- CSRF Regenerate --------------------------------------------------------------------------
public
bool
$CSRFRegenerate
= true
Regenerate token on every submission?
Tags
$CSRFSameSite
-------------------------------------------------------------------------- CSRF SameSite --------------------------------------------------------------------------
public
string
$CSRFSameSite
= 'Lax'
Setting for CSRF SameSite cookie token. Allowed values are:
- None
- Lax
- Strict
- ''
Defaults to Lax
as recommended in this link:
Tags
$CSRFTokenName
-------------------------------------------------------------------------- CSRF Token Name --------------------------------------------------------------------------
public
string
$CSRFTokenName
= 'csrf_test_name'
The token name.
Tags
$defaultLocale
-------------------------------------------------------------------------- Default Locale --------------------------------------------------------------------------
public
string
$defaultLocale
= 'es'
The Locale roughly represents the language and location that your visitor is viewing the site from. It affects the language strings and other strings (like currency markers, numbers, etc), that your program should run under for this request.
$forceGlobalSecureRequests
-------------------------------------------------------------------------- URI PROTOCOL --------------------------------------------------------------------------
public
bool
$forceGlobalSecureRequests
= false
If true, this will force every request made to this application to be made via a secure connection (HTTPS). If the incoming request is not secure, the user will be redirected to a secure version of the page and the HTTP Strict Transport Security header will be set.
$indexPage
-------------------------------------------------------------------------- Index File --------------------------------------------------------------------------
public
string
$indexPage
= 'index.php'
Typically this will be your index.php file, unless you've renamed it to something else. If you are using mod_rewrite to remove the page set this variable so that it is blank.
$negotiateLocale
-------------------------------------------------------------------------- Negotiate Locale --------------------------------------------------------------------------
public
bool
$negotiateLocale
= true
If true, the current Request object will automatically determine the language to use based on the value of the Accept-Language header.
If false, no automatic detection will be performed.
$proxyIPs
-------------------------------------------------------------------------- Reverse Proxy IPs --------------------------------------------------------------------------
public
string|array<string|int, string>
$proxyIPs
= ''
If your server is behind a reverse proxy, you must whitelist the proxy IP addresses from which CodeIgniter should trust headers such as HTTP_X_FORWARDED_FOR and HTTP_CLIENT_IP in order to properly identify the visitor's IP address.
You can use both an array or a comma-separated list of proxy addresses, as well as specifying whole subnets. Here are a few examples:
Comma-separated: '10.0.1.200,192.168.5.0/24' Array: ['10.0.1.200', '192.168.5.0/24']
$registrars
An optional array of classes that will act as Registrars for rapidly setting config class properties.
public
static array<string|int, mixed>
$registrars
= []
$sessionCookieName
-------------------------------------------------------------------------- Session Cookie Name --------------------------------------------------------------------------
public
string
$sessionCookieName
= 'ci_session'
The session cookie name, must contain only [0-9a-z_-] characters
$sessionDriver
-------------------------------------------------------------------------- Session Driver --------------------------------------------------------------------------
public
string
$sessionDriver
= 'CodeIgniter\Session\Handlers\FileHandler'
The session storage driver to use:
-
CodeIgniter\Session\Handlers\FileHandler
-
CodeIgniter\Session\Handlers\DatabaseHandler
-
CodeIgniter\Session\Handlers\MemcachedHandler
-
CodeIgniter\Session\Handlers\RedisHandler
$sessionExpiration
-------------------------------------------------------------------------- Session Expiration --------------------------------------------------------------------------
public
int
$sessionExpiration
= 7200
The number of SECONDS you want the session to last. Setting to 0 (zero) means expire when the browser is closed.
$sessionMatchIP
-------------------------------------------------------------------------- Session Match IP --------------------------------------------------------------------------
public
bool
$sessionMatchIP
= false
Whether to match the user's IP address when reading the session data.
WARNING: If you're using the database driver, don't forget to update your session table's PRIMARY KEY when changing this setting.
$sessionRegenerateDestroy
-------------------------------------------------------------------------- Session Regenerate Destroy --------------------------------------------------------------------------
public
bool
$sessionRegenerateDestroy
= false
Whether to destroy session data associated with the old session ID when auto-regenerating the session ID. When set to FALSE, the data will be later deleted by the garbage collector.
$sessionSavePath
-------------------------------------------------------------------------- Session Save Path --------------------------------------------------------------------------
public
string
$sessionSavePath
= WRITEPATH . 'session'
The location to save sessions to and is driver dependent.
For the 'files' driver, it's a path to a writable directory. WARNING: Only absolute paths are supported!
For the 'database' driver, it's a table name. Please read up the manual for the format with other session drivers.
IMPORTANT: You are REQUIRED to set a valid save path!
$sessionTimeToUpdate
-------------------------------------------------------------------------- Session Time to Update --------------------------------------------------------------------------
public
int
$sessionTimeToUpdate
= 300
How many seconds between CI regenerating the session ID.
$supportedLocales
-------------------------------------------------------------------------- Supported Locales --------------------------------------------------------------------------
public
array<string|int, string>
$supportedLocales
= ['es', 'en', 'it', 'fr']
If $negotiateLocale is true, this array lists the locales supported by the application in descending order of priority. If no match is found, the first locale will be used.
$uriProtocol
-------------------------------------------------------------------------- URI PROTOCOL --------------------------------------------------------------------------
public
string
$uriProtocol
= 'REQUEST_URI'
This item determines which getServer global should be used to retrieve the URI string. The default setting of 'REQUEST_URI' works for most servers. If your links do not seem to work, try one of the other delicious flavors:
'REQUEST_URI' Uses $_SERVER['REQUEST_URI'] 'QUERY_STRING' Uses $_SERVER['QUERY_STRING'] 'PATH_INFO' Uses $_SERVER['PATH_INFO']
WARNING: If you set this to 'PATH_INFO', URIs will always be URL-decoded!
$didDiscovery
Has module discovery happened yet?
protected
static bool
$didDiscovery
= false
$moduleConfig
The modules configuration.
protected
static Modules
$moduleConfig
Methods
__construct()
Will attempt to get environment variables with names that match the properties of the child class.
public
__construct() : mixed
The "shortPrefix" is the lowercase-only config class name.
Return values
mixed —getEnvValue()
Retrieve an environment-specific configuration setting
protected
getEnvValue(string $property, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —initEnvValue()
Initialization an environment-specific configuration setting
protected
initEnvValue(mixed &$property, string $name, string $prefix, string $shortPrefix) : mixed
Parameters
- $property : mixed
- $name : string
- $prefix : string
- $shortPrefix : string
Return values
mixed —registerProperties()
Provides external libraries a simple way to register one or more options into a config file.
protected
registerProperties() : mixed