我試圖使用FOSUserBundle,我按照覆蓋該軟件包的文檔上的說明,但當我嘗試訪問/註冊時,/登錄工程(I沒有覆蓋它):FOSUserBundle覆蓋註冊,但無法加載類型錯誤
Could not load type "app_user_registration"
500 Internal Server Error - InvalidArgumentException
配置
Symfony的版本:3.1.7
FOSUserBundle版本:DEV-主
我的文件
應用程序/配置/ services.yml:
services:
app.form.registration:
class: CoreBundle\Form\Type\RegistrationFormType
tags:
- { name: form.type, alias: app_user_registration }
應用程序/配置/ config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: CoreBundle\Entity\User
registration:
form:
type: app_user_registration
的src/CoreBundle /Form/Type/RegistrationFormType.php
<?php
// src/CoreBundle/Form/Type/RegistrationFormType.php
namespace CoreBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class RegistrationFormType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name');
}
public function getParent()
{
return 'fos_user_registration';
}
public function getName()
{
return 'app_user_registration';
}
}
?>
的src/viwa/UserBundle /控制器/ RegistrationController.php:
<?php
// src/viwa/UserBundle/Controller/RegistrationController.php
namespace viwa\UserBundle\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use FOS\UserBundle\Controller\RegistrationController as BaseController;
class RegistrationController extends BaseController
{
// Don't need to change this right now.
}
?>
的src/viwa/UserBundle/viwaUserBundle.php:
<?php
// src/viwa/UserBundle/viwaUserBundle.php
namespace viwa\UserBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class viwaUserBundle extends Bundle
{
public function getParent()
{
return 'FOSUserBundle';
}
}
如果需要其他任何事情來幫助我,我編輯我的帖子。
希望任何人都可以幫助我。
在你的config.yml中,不是使用別名app_user_resitration,而是使用CoreBundle \ Form \ Type \ RegistrationFormType。你的CoreBundle/Form/Type/RegistrationFormType中的getParent()應該返回''FOS \ UserBundle \ Form \ Type \ RegistrationFormType'。如果我看到更多將再次評論 – pogeybait