I have this error on my Symfony 6.0 project:
Attempted to load class "TwigComponentBundle" from namespace "SymfonyUXTwigComponent".
Did you forget a "use" statement for another namespace?
When I’m doing a "composer require symfony/framework-bundle -W", here’s my Terminal output:
./composer.json has been updated
Running composer update symfony/twig-bundle
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package league/uri-parser is abandoned, you should avoid using it. No replacement was suggested.
Package deployer/phar-update is abandoned, you should avoid using it. No replacement was suggested.
Generating optimized autoload files
106 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Run composer recipes at any time to see the status of your Symfony recipes.
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 255
!! SymfonyComponentErrorHandlerErrorClassNotFoundError {#92
!! #message: """
!! Attempted to load class "TwigComponentBundle" from namespace "SymfonyUXTwigComponent".n
!! Did you forget a "use" statement for another namespace?
!! """
!! #code: 0
!! #file: "D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyframework-bundleKernelMicroKernelTrait.php"
!! #line: 132
!! trace: {
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyframework-bundleKernelMicroKernelTrait.php:132 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyhttp-kernelKernel.php:386 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyhttp-kernelKernel.php:128 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyframework-bundleConsoleApplication.php:168 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyframework-bundleConsoleApplication.php:74 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyconsoleApplication.php:171 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorsymfonyruntimeRunnerSymfonyConsoleApplicationRunner.php:54 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguevendorautoload_runtime.php:35 { …}
!! D:pierreprojetscatalogue servicesdockerphp8cataloguebinconsole:11 {
!! ›
!! › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "D:pierreprojetscatalogue servicesdockerphp8cataloguevendorautoload_runtime.php"
!! }
!! }
!! }
!! }
!! 2023-06-14T08:57:53+00:00 [critical] Uncaught Error: Class "SymfonyUXTwigComponentTwigComponentBundle" not foundtype here
Here’s my composer.json:
{
"name": "symfony/website-skeleton",
"type": "project",
"license": "proprietary",
"description": "A skeleton to start a new Symfony website",
"minimum-stability": "stable",
"prefer-stable": true,
"require": {
"php": ">=7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"amphp/http-client": "^4.6",
"composer/package-versions-deprecated": "1.11.99.4",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.10",
"phpdocumentor/reflection-docblock": "^5.2",
"symfony/asset": "^5.3",
"symfony/config": "^5.4",
"symfony/console": "^5.3",
"symfony/dependency-injection": "^5.4",
"symfony/dotenv": "^5.3",
"symfony/expression-language": "^5.3",
"symfony/finder": "^5.4",
"symfony/flex": "^1.16",
"symfony/form": "^5.3",
"symfony/framework-bundle": "^5.3",
"symfony/http-client": "^5.3",
"symfony/intl": "^5.3",
"symfony/mailer": "^5.3",
"symfony/mime": "^5.3",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "^5.3",
"symfony/process": "^5.3",
"symfony/property-access": "^5.3",
"symfony/property-info": "^5.3",
"symfony/proxy-manager-bridge": "^5.3",
"symfony/requirements-checker": "^2.0",
"symfony/runtime": "^5.3",
"symfony/security-bundle": "^5.3",
"symfony/serializer": "^5.3",
"symfony/stimulus-bundle": "^2.9",
"symfony/string": "^5.3",
"symfony/translation": "^5.3",
"symfony/twig-bundle": "^5.3",
"symfony/validator": "^5.3",
"symfony/web-link": "^5.3",
"symfony/web-profiler-bundle": "^5.3",
"symfony/webpack-encore-bundle": "^1.14",
"symfony/yaml": "^5.3",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
},
"require-dev": {
"andres-montanez/magallanes": "^4.0",
"deployer/deployer": "^6.8",
"symfony/browser-kit": "^5.3",
"symfony/css-selector": "^5.3",
"symfony/debug-bundle": "^5.3",
"symfony/maker-bundle": "^1.0",
"symfony/phpunit-bridge": "^5.3",
"symfony/stopwatch": "^5.3"
},
"config": {
"optimize-autoloader": true,
"preferred-install": {
"*": "dist"
},
"sort-packages": true,
"allow-plugins": {
"symfony/flex": true,
"symfony/runtime": true
}
},
"autoload": {
"psr-4": {
"App\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\Tests\": "tests/"
}
},
"replace": {
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
},
"conflict": {
"symfony/symfony": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"requirements-checker": "script"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"extra": {
"symfony": {
"allow-contrib": false,
"require": "^5.3",
"docker": true
}
}
}
Bundles.php here:
<?php
return [
SymfonyBundleFrameworkBundleFrameworkBundle::class => ['all' => true],
SymfonyBundleTwigBundleTwigBundle::class => ['all' => true],
SymfonyBundleWebProfilerBundleWebProfilerBundle::class => ['dev' => true, 'test' => true],
SymfonyBundleMonologBundleMonologBundle::class => ['all' => true],
SymfonyBundleDebugBundleDebugBundle::class => ['dev' => true],
DoctrineBundleDoctrineBundleDoctrineBundle::class => ['all' => true],
DoctrineBundleMigrationsBundleDoctrineMigrationsBundle::class => ['all' => true],
SymfonyBundleSecurityBundleSecurityBundle::class => ['all' => true],
TwigExtraTwigExtraBundleTwigExtraBundle::class => ['all' => true],
SymfonyBundleMakerBundleMakerBundle::class => ['dev' => true],
SymfonyUXTwigComponentTwigComponentBundle::class => ['all' => true],
SymfonyUXLiveComponentLiveComponentBundle::class => ['all' => true],
SymfonyWebpackEncoreBundleWebpackEncoreBundle::class => ['all' => true],
SymfonyUXVueVueBundle::class => ['all' => true],
SymfonyUXAutocompleteAutocompleteBundle::class => ['all' => true],
SymfonyUXStimulusBundleStimulusBundle::class => ['all' => true],
];
Any help or anyone who also did encountered such an error ?
Thanks !
2
Answers
run
composer require symfony/ux-twig-component
See the docs here
Thank you Craigh it solved my issue