Symfony架构:更新错误

时间:2017-06-27 17:29:10

标签: php symfony doctrine-orm many-to-one

我有一个错误,我无法解决,因为我无法找到问题。 控制台中的错误说:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting ',' or ';'

尝试使用时:

php bin/console doctrine:schema:update --dump-sql

我试图为我的学习做作业,但我找不到问题。 添加实体中的下一个字段" client_order.php"后,该命令无效:

/**
 * @ORM\ManyToOne(targetEntity="order_line")
 * @ORM\JoinColumn(name="order_line_id", referencedColumnName="id")
 */
private $order_line;

/**
 * @ORM\ManyToOne(targetEntity="user")
 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
 */
private $user;

/**
 * @ORM\ManyToOne(targetEntity="Product")
 * @ORM\JoinColumn(name="Product_id", referencedColumnName="id")
 */
private $Product;

在我添加symfony中的新字段后,我使用了命令:

php bin/console doctrine:generate:entities TuinadviesBundle:client_order

以下是完整文件:     

namespace TuinadviesBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* client_order
*
* @ORM\Table(name="client_order")
* @ORM\Entity(repositoryClass="TuinadviesBundle\Repository\client_orderRepository")
*/
class client_order
{
/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="date", type="date")
 */
private $date;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="expiration_date", type="date")
 */
private $expirationDate;

/**
 * @ORM\ManyToOne(targetEntity="order_line")
 * @ORM\JoinColumn(name="order_line_id", referencedColumnName="id")
 */
private $order_line;

/**
 * @ORM\ManyToOne(targetEntity="user")
 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
 */
private $user;

/**
 * @ORM\ManyToOne(targetEntity="Product")
 * @ORM\JoinColumn(name="Product_id", referencedColumnName="id")
 */
private $Product;

/**
 * Get id
 *
 * @return int
 */
public function getId()
{
    return $this->id;
}

/**
 * Set date
 *
 * @param \DateTime $date
 *
 * @return client_order
 */
public function setDate($date)
{
    $this->date = $date;

    return $this;
}

/**
 * Get date
 *
 * @return \DateTime
 */
public function getDate()
{
    return $this->date;
}

/**
 * Set expirationDate
 *
 * @param \DateTime $expirationDate
 *
 * @return client_order
 */
public function setExpirationDate($expirationDate)
{
    $this->expirationDate = $expirationDate;

    return $this;
}

/**
 * Get expirationDate
 *
 * @return \DateTime
 */
public function getExpirationDate()
{
    return $this->expirationDate;
}

/**
 * Set orderLine
 *
 * @param \TuinadviesBundle\Entity\order_line $orderLine
 *
 * @return client_order
 */
public function setOrderLine(\TuinadviesBundle\Entity\order_line $orderLine = null)
{
    $this->order_line = $orderLine;

    return $this;
}

/**
 * Get orderLine
 *
 * @return \TuinadviesBundle\Entity\order_line
 */
public function getOrderLine()
{
    return $this->order_line;
}

/**
 * Set user
 *
 * @param \TuinadviesBundle\Entity\user $user
 *
 * @return client_order
 */
public function setUser(\TuinadviesBundle\Entity\user $user = null)
{
    $this->user = $user;

    return $this;
}

/**
 * Get user
 *
 * @return \TuinadviesBundle\Entity\user
 */
public function getUser()
{
    return $this->user;
}

/**
 * Set product
 *
 * @param \TuinadviesBundle\Entity\Product $product
 *
 * @return client_order
 */
public function setProduct(\TuinadviesBundle\Entity\Product $product = null)
{
    $this->Product = $product;

    return $this;
}

/**
 * Get product
 *
 * @return \TuinadviesBundle\Entity\Product
 */
public function getProduct()
{
    return $this->Product;
}
}

我添加的所有课程都是正确的(即使是带有大写字母P的产品(误做了))。

有谁能告诉我我做错了什么?

提前致谢:)

1 个答案:

答案 0 :(得分:0)

Jep是在user.php我忘了“;”但我可以发誓,我没有编辑那个..哦,非常感谢,无论如何:)

    C:\xampp\htdocs\tuinadvies>php bin/console doctrine:schema:update --dump-sql 
    -vvv
    21:50:41 INFO      [php] User Deprecated: The 
    "Symfony\Component\Console\Event\ConsoleExceptionEvent" class is deprecated 
    since version 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent 
    instead.
    [
    "exception" => Symfony\Component\Debug\Exception\ContextErrorException {
    -context: [
      "class" => "Symfony\Component\Console\Event\ConsoleExceptionEvent",
      "file" => 

 "C:\xampp\htdocs\tuinadvies\vendor\composer/../symfony/symfony/src/Symfony/Component\Console\Event\ConsoleExceptionEvent.php"
    ],
    #message: "User Deprecated: The 
    "Symfony\Component\Console\Event\ConsoleExceptionEvent" class is deprecated since version 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.",
    #code: 0,
    #file: "C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Event\ConsoleExceptionEvent.php",
    #line: 14,
    #severity: E_USER_DEPRECATED,
    trace: {
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Event\ConsoleExceptionEvent.php:14: {
        : ,
        : @trigger_error(sprintf('The "%s" class is deprecated since version 3.3 and will be removed in 4.0. Use the ConsoleErrorEvent instead.', ConsoleExceptionEvent::class), E_USER_DEPRECATED);,
        :
      },
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Debug\DebugClassLoader.php:144: {
        : if ($file = $this->classLoader[0]->findFile($class)) {,
        :     require_once $file;,
        : },
        arguments: {
          "C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Event\ConsoleExceptionEvent.php"
        }
      },
      Symfony\Component\Debug\DebugClassLoader->loadClass(): {},
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:897: {
        : $x = $e instanceof \Exception ? $e : new FatalThrowableError($e);,
        : $event = new ConsoleExceptionEvent($command, $input, $output, $x, $x->getCode());,
        : $this->dispatcher->dispatch(ConsoleEvents::EXCEPTION, $event);,
        arguments: {
          $class_name: "Symfony\Component\Console\Event\ConsoleExceptionEvent"
        }
      },
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:223: {
        : $this->runningCommand = $command;,
        : $exitCode = $this->doRunCommand($command, $input, $output);,
        : $this->runningCommand = null;,
        arguments: {
          $command: Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand { …},
          $input: Symfony\Component\Console\Input\ArgvInput {#1 …},
          $output: Symfony\Component\Console\Output\ConsoleOutput {#2 …}
        }
      },
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:81: {
        : ,
        :     return parent::doRun($input, $output);,
        : },
        arguments: {
          $input: Symfony\Component\Console\Input\ArgvInput {#1 …},
          $output: Symfony\Component\Console\Output\ConsoleOutput {#2 …}
        }
      },
      C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:130: {
        :     $e = null;,
        :     $exitCode = $this->doRun($input, $output);,
        : } catch (\Exception $x) {,
        arguments: {
          $input: Symfony\Component\Console\Input\ArgvInput {#1 …},
          $output: Symfony\Component\Console\Output\ConsoleOutput {#2 …}
        }
      },
      C:\xampp\htdocs\tuinadvies\bin\console:28: {
        : $application = new Application($kernel);,
        : $application->run($input);,
        : ,
        arguments: {
          $input: Symfony\Component\Console\Input\ArgvInput {#1 …}
        }
      }
    }
  }
]
[]


  [Symfony\Component\Debug\Exception\FatalThrowableError]
  Parse error: syntax error, unexpected 'public' (T_PUBLIC), expecting ',' or ';'


Exception trace:
 () at C:\xampp\htdocs\tuinadvies\src\TuinadviesBundle\Entity\user.php:108
 Doctrine\Common\Persistence\Mapping\Driver\AnnotationDriver->getAllClassNames() at C:\xampp\htdocs\tuinadvies\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain.php:128
 Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain->getAllClassNames() at C:\xampp\htdocs\tuinadvies\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php:114
 Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getAllMetadata() at C:\xampp\htdocs\tuinadvies\vendor\doctrine\orm\lib\Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand.php:59
 Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() at C:\xampp\htdocs\tuinadvies\vendor\doctrine\doctrine-bundle\Command\Proxy\UpdateSchemaDoctrineCommand.php:50
 Doctrine\Bundle\DoctrineBundle\Command\Proxy\UpdateSchemaDoctrineCommand->execute() at C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:264
 Symfony\Component\Console\Command\Command->run() at C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:887
 Symfony\Component\Console\Application->doRunCommand() at C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:223
 Symfony\Component\Console\Application->doRun() at C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:81
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at C:\xampp\htdocs\tuinadvies\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:130
 Symfony\Component\Console\Application->run() at C:\xampp\htdocs\tuinadvies\bin\console:28

doctrine:schema:update [--complete] [--dump-sql] [-f|--force] [--em [EM]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>