CodeIgniter v4.5 API

FileLocatorCached
in package
implements FileLocatorInterface

FinalYes

FileLocator with Cache

Tags
see
FileLocatorCachedTest

Table of Contents

Interfaces

FileLocatorInterface
Allows loading non-class files in a namespaced manner.

Properties

$cache  : array<string, array<string, mixed>>
Cache data
$cacheHandler  : CacheInterface|FileVarExportHandler
$cacheKey  : string
$cacheUpdated  : bool
Is the cache updated?
$locator  : FileLocator

Methods

__construct()  : mixed
__destruct()  : mixed
deleteCache()  : void
Delete cache data
findQualifiedNameFromPath()  : false|string
Find the qualified name of a file according to the namespace of the first matched namespace path.
getClassname()  : string
Examines a file and returns the fully qualified class name.
listFiles()  : array<int, string>
Scans the defined namespaces, returning a list of all files that are contained within the subpath specified by $path.
listNamespaceFiles()  : array<int, string>
Scans the provided namespace, returning a list of all files that are contained within the sub path specified by $path.
locateFile()  : false|string
Attempts to locate a file by examining the name for a namespace and looking through the PSR-4 namespaced files that we know about.
search()  : array<int, string>
Searches through all of the defined namespaces looking for a file.
loadCache()  : void
saveCache()  : void

Properties

$cache

Cache data

private array<string, array<string, mixed>> $cache = []

[method => data] E.g., [ 'search' => [$path => $foundPaths], ]

Methods

findQualifiedNameFromPath()

Find the qualified name of a file according to the namespace of the first matched namespace path.

public findQualifiedNameFromPath(string $path) : false|string
Parameters
$path : string
Return values
false|string

The qualified name or false if the path is not found

getClassname()

Examines a file and returns the fully qualified class name.

public getClassname(string $file) : string
Parameters
$file : string
Return values
string

listFiles()

Scans the defined namespaces, returning a list of all files that are contained within the subpath specified by $path.

public listFiles(string $path) : array<int, string>
Parameters
$path : string
Return values
array<int, string>

List of file paths

listNamespaceFiles()

Scans the provided namespace, returning a list of all files that are contained within the sub path specified by $path.

public listNamespaceFiles(string $prefix, string $path) : array<int, string>
Parameters
$prefix : string
$path : string
Return values
array<int, string>

List of file paths

locateFile()

Attempts to locate a file by examining the name for a namespace and looking through the PSR-4 namespaced files that we know about.

public locateFile(string $file[, string|null $folder = null ][, string $ext = 'php' ]) : false|string
Parameters
$file : string

The relative file path or namespaced file to locate. If not namespaced, search in the app folder.

$folder : string|null = null

The folder within the namespace that we should look for the file. If $file does not contain this value, it will be appended to the namespace folder.

$ext : string = 'php'

The file extension the file should have.

Return values
false|string

The path to the file, or false if not found.

Searches through all of the defined namespaces looking for a file.

public search(string $path[, string $ext = 'php' ][, bool $prioritizeApp = true ]) : array<int, string>
Parameters
$path : string
$ext : string = 'php'
$prioritizeApp : bool = true
Return values
array<int, string>

        
On this page

Search results