无法加载类型 "App\Form\RepeatedType":class 不存在
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.
我尝试过的:
composer install --no-dev --optimize-autoloader
(我在网上找到的)
结果:
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
很奇怪,因为其他表格之前还能用(现在它们坏了说: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
现在它再次工作,除了注册页面(“App\Form\RepeatedType”:class 不存在。)。
值得注意的是,我的自动完成功能在文件夹中找到 Symfony\Component\Form\Extension\Core\Type\RepeatedType
。
有时当我清除缓存时,它会在优化时崩溃。
感谢阅读。
在 symfony 5 中,RepeatedType 的使用语句是 use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
要使用密码字段,您可以输入如下内容:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class,
'required' => false,
'mapped' => false,
'first_options' => ['label' => 'New password'],
'second_options' => ['label' => 'Repeat password'],
]);
我从 synfony 4 升级到 5。然后我尝试测试我的注册页面并得到这个:Could not load type "App\Form\RepeatedType": class does not exist.
我尝试过的:
composer install --no-dev --optimize-autoloader
(我在网上找到的)
结果:
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
很奇怪,因为其他表格之前还能用(现在它们坏了说: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
现在它再次工作,除了注册页面(“App\Form\RepeatedType”:class 不存在。)。
值得注意的是,我的自动完成功能在文件夹中找到 Symfony\Component\Form\Extension\Core\Type\RepeatedType
。
有时当我清除缓存时,它会在优化时崩溃。
感谢阅读。
在 symfony 5 中,RepeatedType 的使用语句是 use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
要使用密码字段,您可以输入如下内容:
$builder
->add('password', RepeatedType::class, [
'type' => PasswordType::class,
'required' => false,
'mapped' => false,
'first_options' => ['label' => 'New password'],
'second_options' => ['label' => 'Repeat password'],
]);