Documentation

Services extends BaseService
in package

Services Configuration file.

Services are simply other classes/libraries that the system uses to do its job. This is used by CodeIgniter to allow the core of the framework to be swapped out easily without affecting the usage within the rest of your application.

This file holds any application-specific services, or service overrides that you might need. An example has been included with the general method format you should use for your service methods. For more examples, see the core Services file at system/Config/Services.php.

Table of Contents

$discovered  : bool
Have we already discovered other Services?
$instances  : array<string|int, mixed>
Cache for instance of any services that have been requested as a "shared" instance.
$mocks  : array<string|int, mixed>
Mock objects for testing which are returned if exist.
$services  : array<string|int, mixed>
A cache of other service classes we've found.
$serviceNames  : array<string|int, string>
A cache of the names of services classes found.
__callStatic()  : mixed
Provides the ability to perform case-insensitive calling of service names.
autoloader()  : Autoloader
The Autoloader class is the central class that handles our spl_autoload_register method, and helper methods.
cache()  :
clirequest()  :
codeigniter()  :
commands()  :
curlrequest()  :
email()  :
encrypter()  :
exceptions()  :
filters()  :
format()  :
honeypot()  :
image()  :
injectMock()  : mixed
Inject mock object for testing.
iterator()  :
language()  :
locator()  : FileLocator
The file locator provides utility methods for looking for non-classes within namespaced folders, as well as convenience methods for loading 'helpers', and 'libraries'.
logger()  :
migrations()  :
negotiator()  :
pager()  :
parser()  :
redirectresponse()  :
renderer()  :
request()  :
reset()  : mixed
Reset shared instances and mocks for testing.
resetSingle()  : mixed
Resets any mock and shared instances for a single service.
response()  :
router()  :
routes()  :
security()  :
serviceExists()  : string|null
Check if the requested service is defined and return the declaring class. Return null if not found.
session()  :
throttler()  :
timer()  :
toolbar()  :
typography()  :
uri()  :
validation()  :
viewcell()  :
buildServicesCache()  : void
discoverServices()  : mixed
Will scan all psr4 namespaces registered with system to look for new Config\Services files. Caches a copy of each one, then looks for the service method in each, returning an instance of the service, if available.
getSharedInstance()  : mixed
Returns a shared instance of any of the class' services.

Properties

$discovered

Have we already discovered other Services?

protected static bool $discovered = false

$instances

Cache for instance of any services that have been requested as a "shared" instance.

protected static array<string|int, mixed> $instances = []

Keys should be lowercase service names.

$mocks

Mock objects for testing which are returned if exist.

protected static array<string|int, mixed> $mocks = []

$services

A cache of other service classes we've found.

protected static array<string|int, mixed> $services = []

$serviceNames

A cache of the names of services classes found.

private static array<string|int, string> $serviceNames = []

Methods

__callStatic()

Provides the ability to perform case-insensitive calling of service names.

public static __callStatic(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>
Return values
mixed

autoloader()

The Autoloader class is the central class that handles our spl_autoload_register method, and helper methods.

public static autoloader([bool $getShared = true ]) : Autoloader
Parameters
$getShared : bool = true
Return values
Autoloader

cache()

public static cache(Cache $config = null, mixed $getShared) :
Parameters
$config = null : Cache
$getShared : mixed
Return values

clirequest()

public static clirequest(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

codeigniter()

public static codeigniter(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

commands()

public static commands(mixed $getShared) :
Parameters
$getShared : mixed
Return values

curlrequest()

public static curlrequest(mixed $options, ResponseInterface $response = null, App $config = null, mixed $getShared) :
Parameters
$options : mixed
$response = null : ResponseInterface
$config = null : App
$getShared : mixed
Return values

email()

public static email(mixed $config, mixed $getShared) :
Parameters
$config : mixed
$getShared : mixed
Return values

encrypter()

public static encrypter(Encryption $config = null, mixed $getShared) :
Parameters
$config = null : Encryption
$getShared : mixed
Return values

filters()

public static filters(Filters $config = null, mixed $getShared) :
Parameters
$config = null : Filters
$getShared : mixed
Return values

format()

public static format(Format $config = null, mixed $getShared) :
Parameters
$config = null : Format
$getShared : mixed
Return values

honeypot()

public static honeypot(Honeypot $config = null, mixed $getShared) :
Parameters
$config = null : Honeypot
$getShared : mixed
Return values

image()

public static image(mixed $handler, Images $config = null, mixed $getShared) :
Parameters
$handler : mixed
$config = null : Images
$getShared : mixed
Return values

injectMock()

Inject mock object for testing.

public static injectMock(string $name, mixed $mock) : mixed
Parameters
$name : string
$mock : mixed
Return values
mixed

iterator()

public static iterator(mixed $getShared) :
Parameters
$getShared : mixed
Return values

language()

public static language(mixed $locale, mixed $getShared) :
Parameters
$locale : mixed
$getShared : mixed
Return values

locator()

The file locator provides utility methods for looking for non-classes within namespaced folders, as well as convenience methods for loading 'helpers', and 'libraries'.

public static locator([bool $getShared = true ]) : FileLocator
Parameters
$getShared : bool = true
Return values
FileLocator

logger()

public static logger(mixed $getShared) :
Parameters
$getShared : mixed
Return values

parser()

public static parser(mixed $viewPath, View $config = null, mixed $getShared) :
Parameters
$viewPath : mixed
$config = null : View
$getShared : mixed
Return values

redirectresponse()

public static redirectresponse(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

renderer()

public static renderer(mixed $viewPath, View $config = null, mixed $getShared) :
Parameters
$viewPath : mixed
$config = null : View
$getShared : mixed
Return values

request()

public static request(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

reset()

Reset shared instances and mocks for testing.

public static reset([bool $initAutoloader = false ]) : mixed
Parameters
$initAutoloader : bool = false

Initializes autoloader instance

Return values
mixed

resetSingle()

Resets any mock and shared instances for a single service.

public static resetSingle(string $name) : mixed
Parameters
$name : string
Return values
mixed

response()

public static response(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

routes()

public static routes(mixed $getShared) :
Parameters
$getShared : mixed
Return values

security()

public static security(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

serviceExists()

Check if the requested service is defined and return the declaring class. Return null if not found.

public static serviceExists(string $name) : string|null
Parameters
$name : string
Return values
string|null

session()

public static session(App $config = null, mixed $getShared) :
Parameters
$config = null : App
$getShared : mixed
Return values

throttler()

public static throttler(mixed $getShared) :
Parameters
$getShared : mixed
Return values

timer()

public static timer(mixed $getShared) :
Parameters
$getShared : mixed
Return values

toolbar()

public static toolbar(Toolbar $config = null, mixed $getShared) :
Parameters
$config = null : Toolbar
$getShared : mixed
Return values

typography()

public static typography(mixed $getShared) :
Parameters
$getShared : mixed
Return values

uri()

public static uri(mixed $uri, mixed $getShared) :
Parameters
$uri : mixed
$getShared : mixed
Return values

validation()

public static validation(Validation $config = null, mixed $getShared) :
Parameters
$config = null : Validation
$getShared : mixed
Return values

viewcell()

public static viewcell(mixed $getShared) :
Parameters
$getShared : mixed
Return values

buildServicesCache()

protected static buildServicesCache() : void
Return values
void

discoverServices()

Will scan all psr4 namespaces registered with system to look for new Config\Services files. Caches a copy of each one, then looks for the service method in each, returning an instance of the service, if available.

protected static discoverServices(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
$name : string
$arguments : array<string|int, mixed>
Tags
deprecated
codeCoverageIgnore
Return values
mixed

getSharedInstance()

Returns a shared instance of any of the class' services.

protected static getSharedInstance(string $key, mixed ...$params) : mixed

$key must be a name matching a service.

Parameters
$key : string
$params : mixed
Return values
mixed

Search results