{"record":{"id":"d3c7adfe108d6728","repo":"cakephp/cakephp","slug":"class-s-does-not-exist-or-does-not-extend-cake-core","errorCode":null,"errorMessage":"Class `%s` does not exist or does not extend `Cake\\Core\\PluginInterface`.","messagePattern":"Class `(.+?)` does not exist or does not extend `Cake\\\\Core\\\\PluginInterface`\\.","errorType":"exception","errorClass":"InvalidArgumentException","httpStatus":null,"severity":"error","filePath":"src/Core/PluginCollection.php","lineNumber":265,"sourceCode":"\n    /**\n     * Create a plugin instance from a name/classname and configuration.\n     *\n     * @param class-string<\\Cake\\Core\\PluginInterface>|string $name The plugin name or classname\n     * @param array<string, mixed> $config Configuration options for the plugin.\n     * @return \\Cake\\Core\\PluginInterface\n     * @throws \\Cake\\Core\\Exception\\MissingPluginException When plugin instance could not be created.\n     * @throws \\InvalidArgumentException When class name cannot be found or an empty name is provided.\n     */\n    public function create(string $name, array $config = []): PluginInterface\n    {\n        if ($name === '') {\n            throw new InvalidArgumentException('Plugin name cannot be empty.');\n        }\n\n        if (str_contains($name, '\\\\')) {\n            if (!is_subclass_of($name, PluginInterface::class)) {\n                throw new InvalidArgumentException(sprintf(\n                    'Class `%s` does not exist or does not extend `Cake\\Core\\PluginInterface`.',\n                    $name,\n                ));\n            }\n\n            return new $name($config);\n        }\n\n        $config += ['name' => $name];\n        $namespace = str_replace('/', '\\\\', $name);\n\n        $pos = strpos($name, '/');\n        $namePart = $pos === false ? $name : substr($name, $pos + 1);\n\n        // Check for [Vendor/]Foo/FooPlugin class\n        $className = $namespace . '\\\\' . $namePart . 'Plugin';\n\n        if (!class_exists($className)) {","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/cakephp/cakephp/blob/1128eba9b09f1946df684811350e26f2cef68fac/src/Core/PluginCollection.php#L247-L283","documentation":"PluginCollection::create() accepts FQCNs containing a backslash. If the class exists as a string but is not a subclass of Cake\\Core\\PluginInterface, it throws InvalidArgumentException because it cannot instantiate a valid plugin from it.","triggerScenarios":"Passing an app class name like 'App\\Application' or a typo'd class that does not implement PluginInterface to create()/get().","commonSituations":"Using the Application class name as a plugin name; referencing a plugin class that was renamed when upgrading from Cake 3 to Cake 4/5 (BasePlugin introduction); namespace typos.","solutions":["Pass the plugin name (e.g. 'DebugKit') instead of a class name, letting Cake resolve it","Ensure the referenced class extends Cake\\Core\\BasePlugin (implements PluginInterface) and the namespace/autoload mapping is correct","Run composer dump-autoload so the class can be found"],"exampleFix":"// before\n$plugin = $plugins->create('App\\Application');\n// after\n$plugin = $plugins->create('MyCompany\\MyPlugin\\MyPluginPlugin'); // class extends BasePlugin","handlingStrategy":"try-catch","validationCode":"if (str_contains($name, '\\\\') && !is_subclass_of($name, \\Cake\\Core\\PluginInterface::class)) {\n    throw new \\InvalidArgumentException(\"$name is not a PluginInterface\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $plugins->create($name);\n} catch (\\InvalidArgumentException $e) {\n    // fall back to treating $name as a plugin name, not a class\n}","preventionTips":["Pass short plugin names unless instantiating a custom class","Ensure custom plugin classes extend Cake\\Core\\BasePlugin","Run composer dump-autoload after class renames"],"tags":["cakephp","plugin","class-not-found"],"backgroundTag":"class-not-found","analyzedSha":"1128eba9b09f1946df684811350e26f2cef68fac","analyzedAt":"2026-09-12T12:07:00.388Z","contentChangedAt":"2026-09-12T12:07:00.388Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}