[英]Could not load type "App\Form\RepeatedType": class does not exist
I upgrade from synfony 4 to 5. Then i try to test my registration page and get this: Could not load type "App\Form\RepeatedType": class does not exist.
我从 synfony 4 升级到 5。然后我尝试测试我的注册页面并得到这个:
Could not load type "App\Form\RepeatedType": class does not exist.
What i have try:我有什么尝试:
composer install --no-dev --optimize-autoloader
(i found this online) composer install --no-dev --optimize-autoloader
(我在网上找到的) The result:结果:
Installing dependencies from lock file
Verifying lock file contents can be installed on current platform.
Package operations: 0 installs, 0 updates, 5 removals
- Removing symfony/web-profiler-bundle (v5.4.8)
- Removing symfony/maker-bundle (v1.42.0)
- Removing nikic/php-parser (v4.13.2)
- Removing doctrine/doctrine-fixtures-bundle (3.4.2)
- Removing doctrine/data-fixtures (1.5.3)
Generating optimized autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
69 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
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#83
!! #message: """
!! Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle".\n
!! Did you forget a "use" statement for another namespace?
!! """
!! #code: 0
!! #file: "D:\cours\symfony\blog\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php"
!! #line: 132
!! trace: {
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Kernel\MicroKernelTrait.php:132 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:386 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:786 { …}
!! D:\cours\symfony\blog\vendor\symfony\http-kernel\Kernel.php:128 { …}
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Console\Application.php:168 { …}
!! D:\cours\symfony\blog\vendor\symfony\framework-bundle\Console\Application.php:74 { …}
!! D:\cours\symfony\blog\vendor\symfony\console\Application.php:171 { …}
!! D:\cours\symfony\blog\vendor\symfony\runtime\Runner\Symfony\ConsoleApplicationRunner.php:54 { …}
!! D:\cours\symfony\blog\vendor\autoload_runtime.php:35 { …}
!! D:\cours\symfony\blog\bin\console:11 {
!! ›
!! › require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "D:\cours\symfony\blog\vendor\autoload_runtime.php"
!! }
!! }
!! }
!! }
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-(
!! 2022-05-17T00:33:06+02:00 [critical] Uncaught Error: Class 'Symfony\Bundle\MakerBundle\MakerBundle' not found
!!
Script @auto-scripts was called via post-install-cmd
WEIRD because others forms worked just before (and now they are broken saying: Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle". Did you forget a "use" statement for another namespace?
)很奇怪,因为其他表单之前工作过(现在他们说:
Attempted to load class "MakerBundle" from namespace "Symfony\Bundle\MakerBundle". Did you forget a "use" statement for another namespace?
)
composer require symfony/maker-bundle --dev
Now it's working again except for the registration page ("App\Form\RepeatedType": class does not exist.). composer require symfony/maker-bundle --dev
现在除了注册页面(“App\Form\RepeatedType”:类不存在)之外,它又可以工作了。 It's worth notting that my autocomplet find Symfony\Component\Form\Extension\Core\Type\RepeatedType
in the folder.值得注意的是,我的自动完成在文件夹中找到了
Symfony\Component\Form\Extension\Core\Type\RepeatedType
。 And sometimes when i clear cache, it crash when optimizing.有时当我清除缓存时,它会在优化时崩溃。
Thanks for reading.谢谢阅读。
In symfony 5 the use statement for RepeatedType is use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
在 symfony 5 中,RepeatedType 的使用语句是
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
And to use for let's say a password fiel you would type something like:并使用 for 让我们说一个密码字段,您可以输入以下内容:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class,
'required' => false,
'mapped' => false,
'first_options' => ['label' => 'New password'],
'second_options' => ['label' => 'Repeat password'],
]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.