2

我正在尝试使用 Doctrine 生成用于新应用程序的实体。我以前使用过 Doctrine,从来没有遇到过这个问题,而且我似乎无法找到为什么在网上任何地方都会发生这种情况的答案。我目前正在使用 PHP-7.2 和 Doctrine 版本的 Ubuntu 17.10 上运行它doctrine/orm: ^2.5

php vendor/bin/doctrine orm:convert-mapping --from-database php models/mapping

然后映射文件制作完成后是这样的:

<?php

use Doctrine\ORM\Mapping\ClassMetadataInfo;

$metadata->setInheritanceType(ClassMetadataInfo::INHERITANCE_TYPE_NONE);
$metadata->setPrimaryTable(array(
   'name' => 'subscriptions',
  ));
$metadata->setChangeTrackingPolicy(ClassMetadataInfo::CHANGETRACKING_DEFERRED_IMPLICIT);
$metadata->mapField(array(
   'fieldName' => 'id',
   'columnName' => 'id',
   'type' => 'integer',
   'nullable' => false,
   'options' => 
   array(
   'unsigned' => false,
   ),
   'id' => true,
  ));
$metadata->mapField(array(
   'fieldName' => 'site',
   'columnName' => 'site',
   'type' => 'string',
   'nullable' => false,
   'length' => 25,
   'options' => 
   array(
   'fixed' => false,
   ),
  ));
$metadata->mapField(array(
   'fieldName' => 'endpoint',
   'columnName' => 'endpoint',
   'type' => 'string',
   'nullable' => false,
   'length' => 45,
   'options' => 
   array(
   'fixed' => false,
   ),
  ));
$metadata->mapField(array(
   'fieldName' => 'userpublickey',
   'columnName' => 'userPublicKey',
   'type' => 'string',
   'nullable' => false,
   'length' => 255,
   'options' => 
   array(
   'fixed' => false,
   ),
  ));
$metadata->mapField(array(
   'fieldName' => 'userauthtoken',
   'columnName' => 'userAuthToken',
   'type' => 'string',
   'nullable' => false,
   'length' => 255,
   'options' => 
   array(
   'fixed' => false,
   ),
  ));
$metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_IDENTITY);

然后我尝试运行这个命令:

php vendor/bin/doctrine orm:generate-entities --generate-annotations=true models/entities

我收到一个错误,指出:

PHP Notice:  Undefined variable: metadata

有谁知道为什么 Doctrine 会生成一个具有未定义变量的映射,以及我将如何修复它?

4

0 回答 0