Class PluginConfig
PluginConfig contains all available plugins and their config if/how they should be loaded
Method Summary
-
clearCache() public static
Clear the cached plugins data. Useful for testing.
-
getAppConfig() public static
Get the config how plugins should be loaded with enriched package metadata.
-
getInstalledPlugins() public static
Get an array of all installed plugins and their configuration options.
-
getPackageNameFromPath() protected static
Extract package name from composer.json in the given path.
-
getVersions() public static
Get package versions from composer.lock file.
-
loadInstallerConfig() public static
Load the path information stored in vendor/cakephp-plugins.php
Method Detail
clearCache() ¶ public static
clearCache(): void
Clear the cached plugins data. Useful for testing.
Returns
voidgetAppConfig() ¶ public static
getAppConfig(string|null $path = null): array<string, array<string, mixed>>
Get the config how plugins should be loaded with enriched package metadata.
Parameters
-
string|null$path optional The absolute path to the composer.lock file to retrieve the versions from
Returns
array<string, array<string, mixed>>Plugin name => enriched configuration with package metadata
getInstalledPlugins() ¶ public static
getInstalledPlugins(): array<string, array<string, mixed>>
Get an array of all installed plugins and their configuration options.
Returns an array of plugin configurations with keys:
- bootstrap: Enable bootstrap hook (if isLoaded)
- console: Enable console hook (if isLoaded)
- events: Enable events hook (if isLoaded)
- isLoaded: Whether plugin is configured to load
- isUnknown: Present and set to true when a plugin is configured but not found in the installed plugins list
- middleware: Enable middleware hook (if isLoaded)
- onlyCli: Load only in CLI mode (if isLoaded)
- onlyDebug: Load only in debug mode (if isLoaded)
- optional: Plugin is optional (if isLoaded)
- path: Plugin filesystem path (only present for installed plugins, not for unknown ones)
- routes: Enable routes hook (if isLoaded)
- services: Enable services hook (if isLoaded)
Returns
array<string, array<string, mixed>>Plugin name => configuration
getPackageNameFromPath() ¶ protected static
getPackageNameFromPath(string $path): string
Extract package name from composer.json in the given path.
Parameters
-
string$path The plugin path containing composer.json
Returns
stringThe package name (e.g., 'cakephp/debug-kit')
Throws
Cake\Core\Exception\CakeExceptionWhen composer.json is missing, unreadable, or invalid
getVersions() ¶ public static
getVersions(string|null $path = null): array{packages: array<string, string>, devPackages: array<string, string>}
Get package versions from composer.lock file.
Parameters
-
string|null$path optional The absolute path to the composer.lock file to retrieve the versions from
Returns
array{packages: array<string, string>, devPackages: array<string, string>}Array with 'packages' and 'devPackages' keys
Throws
Cake\Core\Exception\CakeExceptionWhen composer.lock is missing, unreadable, or invalid
loadInstallerConfig() ¶ public static
loadInstallerConfig(): void
Load the path information stored in vendor/cakephp-plugins.php
This file is generated by the cakephp/plugin-installer package and used
to locate plugins on the filesystem as applications can use extra.plugin-paths
in their composer.json file to move plugin outside of vendor/
Returns
void