{"record":{"id":"673b89e28c5ec299","repo":"octobercms/october","slug":"import-class-classname-does-not-exist","errorCode":null,"errorMessage":"Import class '{$className}' does not exist.","messagePattern":"Import class '(.+?)' does not exist\\.","errorType":"exception","errorClass":"SystemException","httpStatus":null,"severity":"error","filePath":"modules/cms/models/ThemeSeed.php","lineNumber":224,"sourceCode":"    {\n        $importName = $instruction['name'] ?? 'Import Data';\n        $className = $instruction['class'] ?? null;\n        $fileName = $instruction['file'] ?? null;\n        $attributes = $instruction['attributes'] ?? null;\n        $matches = $instruction['matches'] ?? null;\n\n        if (!$className) {\n            throw new SystemException(\"Import script is missing definition for 'class'\");\n        }\n        if (!$fileName) {\n            throw new SystemException(\"Import script is missing definition for 'file'\");\n        }\n        if (!$attributes || !is_array($attributes)) {\n            throw new SystemException(\"Import script is missing definition for 'attributes'\");\n        }\n\n        if (!class_exists($className)) {\n            throw new SystemException(\"Import class '{$className}' does not exist.\");\n        }\n\n        $importFile = $this->themePath . '/' . $fileName;\n        if (!File::exists($importFile)) {\n            throw new SystemException(\"Import file '{$fileName}' does not exist.\");\n        }\n\n        $importModel = new $className;\n        $importModel->forceFill($attributes);\n\n        if (method_exists($importModel, 'setSourcePrefix')) {\n            $importModel->setSourcePrefix($this->themePath);\n        }\n\n        $importModel->importFile($importFile, ['matches' => $matches, 'sessionKey' => str_random(40)]);\n\n        $stats = $importModel->getResultStats();\n        $this->note(\"- <info>{$importName}</info>: {$stats->created} Created / {$stats->updated} Updated / {$stats->skippedCount} Skipped\");","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/octobercms/october/blob/b608633a7e8922487d91a8161499020121c3b3bf/modules/cms/models/ThemeSeed.php#L206-L242","documentation":"After the schema checks pass, processSeedInstruction() instantiates the importer - but only after verifying class_exists($className). A non-loadable class name in seeds/data.yaml (wrong namespace, typo, plugin not installed, autoloader not aware) aborts seeding with this SystemException naming the class.","triggerScenarios":"theme:seed on a theme whose data.yaml references a class the app cannot autoload: namespace typo (Acme\\Blog\\Clases\\PostImport), plugin not installed/disabled, YAML double-quoted string where backslashes were mis-escaped, or a newly added class without a fresh composer dump-autoload.","commonSituations":"Shipping a theme that seeds another plugin's models without declaring that plugin as a requirement; moving classes during refactoring without updating seed files; YAML escaping confusion between single and double quotes.","solutions":["Check the exact value: php artisan tinker, then class_exists('Acme\\Blog\\Classes\\PostImport'); - fix namespace/typo until true.","Ensure the plugin providing the class is installed and enabled (backend System > Updates, or plugin:install).","In double-quoted YAML, escape backslashes ('Acme\\\\Blog\\\\...') or use single-quoted scalars.","Run composer dump-autoload if the class was just added."],"exampleFix":"# before - double-quoted YAML ate the backslashes -> class not loadable\nclass: \"Acme\\Blog\\Classes\\PostImport\"\n\n# after - single-quoted scalar keeps namespaces intact\nclass: 'Acme\\Blog\\Classes\\PostImport'","handlingStrategy":"validation","validationCode":"foreach ((array) Yaml::parseFile($themePath . '/seeds/data.yaml') as $i => $ins) {\n    if (!empty($ins['class']) && !class_exists($ins['class'])) {\n        $errors[] = \"instruction {$i}: class {$ins['class']} not loadable\";\n    }\n}","typeGuard":"function seedClassLoadable(string $class): bool\n{\n    return class_exists($class);\n}","tryCatchPattern":"try {\n    \\Artisan::call('theme:seed', ['name' => $themeDir]);\n} catch (\\October\\Rain\\Exception\\SystemException $e) {\n    // check class_exists() in tinker; fix namespace/escaping or install the plugin\n}","preventionTips":["Use single-quoted YAML scalars for fully-qualified class names.","Declare plugin dependencies your seed instructions rely on, and verify installation before seeding.","Run composer dump-autoload after adding importer classes."],"tags":["theme-seed","class-not-found","yaml","autoloader","namespaces"],"backgroundTag":"class-not-found","analyzedSha":"b608633a7e8922487d91a8161499020121c3b3bf","analyzedAt":"2026-08-21T04:24:57.515Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}