Ang*_*elo 2 php symfony fosuserbundle
我尝试使用FOSUserBundle,我按照文档中的说明覆盖了Bundle,但是当我尝试访问/ register时/ login工作(我没有覆盖它)时出现此错误:
Could not load type "app_user_registration"
500 Internal Server Error - InvalidArgumentException
Run Code Online (Sandbox Code Playgroud)
配置
Symfony版本:3.1.7
FOSUserBundle版本:dev-master
我的文件
应用程序/配置/ services.yml:
services:
app.form.registration:
class: CoreBundle\Form\Type\RegistrationFormType
tags:
- { name: form.type, alias: app_user_registration }
Run Code Online (Sandbox Code Playgroud)
应用程序/配置/ config.yml:
fos_user:
db_driver: orm
firewall_name: main
user_class: CoreBundle\Entity\User
registration:
form:
type: app_user_registration
Run Code Online (Sandbox Code Playgroud)
SRC/CoreBundle /表/类型/ 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';
}
}
?>
Run Code Online (Sandbox Code Playgroud)
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.
}
?>
Run Code Online (Sandbox Code Playgroud)
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';
}
}
Run Code Online (Sandbox Code Playgroud)
如果您还需要其他帮助我,我可以编辑我的帖子.
希望有人能帮助我.
你的config.yml文件应该是:
fos_user:
db_driver: orm
firewall_name: main
user_class: CoreBundle\Entity\User
registration:
form:
type: CoreBundle\Form\Type\RegistrationFormType
Run Code Online (Sandbox Code Playgroud)
在你的src/CoreBundle/Form/Type/RegistrationFormType.php,getParent()功能应该是:
public function getParent()
{
return 'FOS\UserBundle\Form\Type\RegistrationFormType';
}
Run Code Online (Sandbox Code Playgroud)