在来之前我尝试了很多东西,我读了很多,如果我找不到我会得到答案的部分,请原谅。我很乐意被指出。
我正在使用基于Symfony的Silex MicroFramework。多年来我还没有完成Php,整个事情很难融入,但很好......我能够设计一些类,现在我正在尝试将jasongrimes / silex-simpleuser包迁移到基于实体的教义实例。 / p>
当我通过控制台从我的主项目安装它们时,我没有问题。我正在尝试更新测试,所以我需要创建架构,当我收到一条好消息 PHP致命错误:未捕获异常'Doctrine \ ORM \ Mapping \ MappingException',消息'Class \ SimpleUser \ Entity \ User不是有效的实体或映射的超类。在/home/thibault/dev/silex-simpleuser/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/MappingException.php:147
我认为生成这个方案的方式有误,我错过了......
<?php
require_once __DIR__ . "/../vendor/autoload.php";
use SimpleUser\UserServiceProvider;
use Silex\Application;
use Silex\Provider;
use Silex\Provider\DoctrineServiceProvider;
use Silex\Provider\SecurityServiceProvider;
use Doctrine\ORM\Tools\SchemaTool;
//phpunit_bootstrap.php
$app = new \Silex\Application();
$app->register(new \Silex\Provider\SecurityServiceProvider(),
array('security.firewalls' => array('dummy-firewall' => array('form' => array())))
);
$app->register(new \Silex\Provider\DoctrineServiceProvider());
$app['db'] = array(
'driver' => 'pdo_sqlite',
'path' => __DIR__.'/../../../cache/test/.ht.sqlite',
);
$app->register(new UserServiceProvider());
/*
* Setup the Schema
*/
$cacheDriver = new \Doctrine\Common\Cache\ArrayCache();
$deleted = $cacheDriver->deleteAll();
$em = $app["user.doctrine.em"];
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
$classes = array(
$em->getClassMetadata('\\SimpleUser\\Entity\\User'),
$em->getClassMetadata('\\SimpleUser\\Entity\\CustomeFields'),
);
$tool->createSchema($classes);
<?php
namespace SimpleUser\Entity;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Doctrine\ORM\Mapping as ORM;
/**
* User
*
* \Doctrine\ORM\Mapping\Entity
* @ORM\Table(name="simple_user_user")
*/
class User implements AdvancedUserInterface, \Serializable
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=true)
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=100, unique=true)
*/
private $email;
/**
* @var string
*
* @ORM\Column(name="password", type="string", length=255)
*/
private $password;
/**
* @var string
*
* @ORM\Column(name="salt", type="string", length=255)
*/
private $salt;
/**
* @var array
*
* @ORM\Column(name="roles", type="array")
*/
private $roles;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=100)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="time_created", type="integer")
*/
private $timeCreated;
/**
* @var string
*
* @ORM\Column(name="username", type="string", length=100, nullable=true, unique=true)
*/
private $username;
/**
* @var boolean
*
* @ORM\Column(name="is_enabled", type="boolean")
*/
private $isEnabled = '1';
/**
* @var string
*
* @ORM\Column(name="confirmation_token", type="string", length=100, nullable=true)
*/
private $confirmationToken;
/**
* @var integer
*
* @ORM\Column(name="time_password_reset_requested", type="integer", nullable=true)
*/
private $timePasswordResetRequested;