Symfony 3.4 没有元数据类来处理错误

2024-05-04

我已经安装了 symfony 3.4 和 学说包

"php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.8",
        "doctrine/doctrine-migrations-bundle": "^1.3",
        "doctrine/orm": "^2.5",
        "incenteev/composer-parameter-handler": "^2.0",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^5.0.0",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.6.4",
        "symfony/symfony": "3.4.*",
        "twig/twig": "^1.0||^2.0"

使用以下命令创建数据库

php bin/console doctrine:database:create

G:\XAMPP\htdocs\project>php bin/console doctrine:schema:validate
[Mapping]  OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.

G:\XAMPP\htdocs\project>php bin/console doctrine:schema:validate
[Mapping]  OK - The mapping files are correct.
[Database] OK - The database schema is in sync with the mapping files.

G:\XAMPP\htdocs\project>php bin/console doctrine:schema:update --force
No Metadata Classes to process.

G:\XAMPP\htdocs\project>

每当我运行 php bin/consoledoctrine:schema:update --force 命令时,它都会抛出类似的错误

没有要处理的元数据类。

我按照文档创建了实体类http://symfony.com/doc/3.4/doctrine.html http://symfony.com/doc/3.4/doctrine.html

产品实体类

<?php

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="product")
 */
class Product
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=100)
     */
    private $name;

    /**
     * @ORM\Column(type="decimal", scale=2)
     */
    private $price;


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

    /**
     * Set name
     *
     * @param string $name
     *
     * @return Product
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set price
     *
     * @param integer $price
     *
     * @return Product
     */
    public function setPrice($price)
    {
        $this->price = $price;

        return $this;
    }

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

是的,我终于发现问题出在John.orm.php我运行时会生成的文件php bin/console doctrine:generate:entity

我使用以下命令创建了实体类

php bin/console doctrine:generate:entity

然后会提示

Welcome to the Doctrine2 entity generator

This command helps you generate Doctrine2 entities.

First, you need to give the entity name you want to generate.
You must use the shortcut notation like AcmeBlogBundle:Post.

The Entity shortcut name: AppBundle:John

Determine the format to use for the mapping information.

Configuration format (yml, xml, php, or annotation) [annotation]: php

Instead of starting with a blank entity, you can add some fields now.
Note that the primary key will be added automatically (named id).

Available types: array, simple_array, json_array, object,
boolean, integer, smallint, bigint, string, text, datetime, datetimetz,
date, time, decimal, float, binary, blob, guid.

New field name (press <return> to stop adding fields): id
 Field "id" is already defined.
New field name (press <return> to stop adding fields): username
Field type [string]: string
Field length [255]:
Is nullable [false]: true
Unique [false]: false

New field name (press <return> to stop adding fields): password
Field type [string]:
Field length [255]:
Is nullable [false]: true
Unique [false]:

New field name (press <return> to stop adding fields): dob
Field type [string]: date
Is nullable [false]: true
Unique [false]:

New field name (press <return> to stop adding fields):


  Entity generation


  created .\src\AppBundle/Entity/John.php
  created .\src\AppBundle/Resources/config/doctrine/
  created .\src\AppBundle/Resources/config/doctrine/John.orm.php
> Generating entity class G:\XAMPP\htdocs\project\src\AppBundle\Entity\John.php:
 OK!
> Generating repository class G:\XAMPP\htdocs\project\src\AppBundle\Repository\J
ohnRepository.php: OK!
> Generating mapping file G:\XAMPP\htdocs\project\src\AppBundle\Resources\config
\doctrine\John.orm.php: OK!


  Everything is OK! Now get to work :).



G:\XAMPP\htdocs\project>

成功后它将创建实体类AppBundle\Entity;文件夹和存储库类AppBundle\Repository;它还会生成John.orm.php in AppBundle\Resources\config\doctrine\John.orm.php

如果我运行删除 John.orm.php 文件后php bin/console doctrine:schema:update --force然后它会生成表格。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Symfony 3.4 没有元数据类来处理错误 的相关文章

  • $_REQUEST、$_GET、$_POST 哪一个最快?

    这些代码中哪一个会更快 temp REQUEST s or if isset GET s temp GET s else temp POST s REQUEST http php net manual en reserved variabl
  • 如何使用 RewriteRule 来为 PHP 修改 $_SERVER['REQUEST_URI'] ?

    有了这个 htaccess RewriteEngine On RewriteRule foo foo 1 here I tried L PT C etc RewriteRule index php L 我已经尝试了第一个 RewriteRu
  • php递归合并

    我需要以某种不同的方式合并一些数组 我使用 array merge recursive 然而 有一些事情我需要改变 但我不知道如何改变 这是来自 php net 的引用 但是 如果数组具有相同的数字键 则后面的值 不会覆盖原始值 但会追加
  • 为什么使用闭包进行赋值而不是直接将值赋给键?

    我当时正在看在 7 10 他添加了一个数据库依赖项并使用闭包来分配值 我的问题是为什么不直接使用直接赋值 我的意思是不这样做 container db capsule 相当于这样做 container db function contain
  • 如何在 PHP 中运行 shell 脚本?

    我正在尝试使用 PHP 触发 shell 脚本的运行 本质上 当用户在我们用 PHP 编写的网站上完成一个操作时 我们希望触发一个 shell 脚本 该脚本本身调用一个 Java 文件 提前致谢 See shell exec http ph
  • 维护 HttpUrlConnection 调用之间的会话(Native/Webview)

    让我从我做的开始desire 我想制作一个应用程序part native and part webviews Problem 维护本机和 webview 部分之间的会话 My 处理方法 this 我打算实现一个本机登录 其中我向用户展示两个
  • Errno 121,写入或更新时出现重复密钥?

    SET OLD UNIQUE CHECKS UNIQUE CHECKS UNIQUE CHECKS 0 SET OLD FOREIGN KEY CHECKS FOREIGN KEY CHECKS FOREIGN KEY CHECKS 0 S
  • 无法显示由 Fine-uploader 上传到 Amazon s3 的图像

    我现在尝试设置fineuploader s3以显示在aws服务器上成功上传的文件的图像 如示例页面上所做的那样 http fineuploader com s3 demo http fineuploader com s3 demo 我 仍然
  • 如何在 WordPress/WooCommerce 3+ 中向评论表单添加自定义字段

    我正在尝试在产品评论中添加 电话 字段 WooCommerce 3 针对未注册用户 来宾 电话号码只能由管理员在管理面板中看到 电话字段需要填写 Required 我尝试了这段代码 但这不起作用 function true phone nu
  • Laravel 上传前如何压缩图像?

    我正在制作一个图片库网站 用户可以在其中上传任何图像 它们将显示在前端 我需要在不影响图像质量的情况下压缩图像 以减小图像大小 以便页面加载速度不会影响那么大 我使用以下代码来上传图像 rules array file gt require
  • MySQL 中布尔值的 TINYINT 与 ENUM(0, 1)

    MyISAM 表和 MySQL 5 1 中具有 0 和 1 值的 Tinyint 或 ENUM 0 1 哪个更好 您可以使用BIT 1 如中提到的MySQL 5 1 参考 http dev mysql com doc refman 5 1
  • 原则 2 缓存:我可以将缓存与 Repository::find*() 一起使用吗?

    我是缓存新手 从文档中 我可以在查询中使用缓存 但是像这样的方法呢 em gt find Application Models project 1 如果你寻找一种自动性 我认为遮阳篷不是 他们不是这样的东西 我自己也在寻找这样的东西 您可以
  • 在 BIRT 中输入参数后更新数据集查询

    在 BIRT 报告设计中传递参数后 如何更改或更新数据集的查询 详细说明 我有一个如下所示的查询 WHERE 该参数标记可以保存不同的值 在用户输入参数后 它看起来像这样 例如 WHERE column name 1 or WHERE co
  • phpstorm xdebug 与 symfony2 项目

    我正在尝试使用 xdebug 和 phpstorm 调试 symfony2 应用程序 我的本地开发环境是Ubuntu 14 04 with apache2 Xdebug版本是2 2 7 我在另一个 php 不是 symfony2 项目上使用
  • 如何使用xquery查找节点并向其添加子节点?

    是否可以使用xpath xquery查询特定的xml节点 然后向其导入 添加子节点 示例 代码取自http codepad org gJ1Y2LjM http codepad org gJ1Y2LjM 这是在类似的问题中提出的 但不相同 1
  • PHP:如何检查总数。 URL 中的参数?

    我正在使用 REQUEST 检索参数 有没有办法找到总数 URL 中的参数 而不是检索每个参数然后进行计数 这将为您提供总数 分隔的 URL 查询参数 count explode SERVER QUERY STRING 如果您只想要唯一的参
  • 使用 html5 分块上传文件

    我正在尝试使用 html5 的文件 API 分块上传文件 然后在服务器端用 php 重新组装它 我正在上传视频 但是当我在服务器端合并文件时 大小增加了 并且它变成了无效文件 请注意 以下 html5 代码仅适用于 chrome 浏览器 在
  • MySQL 正在将我的时间戳值转换为 0000-00-00

    我是 PHP 新手 目前仍在学习中 我认为我的注册表有问题 username password email全部成功插入MySQL registered and last seen不要 我以为我正在使用getTimestamp 错了 但它呼应
  • SimpleXML插入处理指令(样式表)

    我想集成一个XSL文件在一个XML给我的字符串php CURL命令 我试过这个 output XML gived me by curl option hotel simplexml load string output hotel gt a
  • mod_rewrite, .htaccess 连接mysql数据库

    我希望 htaccess 文件中的 mod rewrite 链接到 mysql 数据库以向我提供映射信息 具体来说 我使用单个代码库来托管多个站点 因此 如果用户请求图像 例如 http www example com images car

随机推荐