symfony 5.1 捆绑迁移导致没有要处理的映射信息

2023-12-30

我正在 DDD 下开发 Symfony 5.1 项目,因此我对所有默认文件夹进行了一些更改。

我在 src 文件夹中有 2 个包,目前我只在其中一个包中有实体。

我使用命令 make:user 生成了实体用户及其存储库,然后移动文件并更改命名空间、路由、配置等

当我跑步时php bin/console make:migration我收到错误“没有要处理的映射信息”

$ run php bin/console make:migration -v

In NoMappingFound.php line 13:

  [Doctrine\Migrations\Provider\Exception\NoMappingFound]
  No mapping information to process

这些文件夹是:

src
 |-- Smartlink
        |-- UserBundle/SmartlinkUserBundle.php
               |-- Application
               |-- Domain
               |     |-- Entity/User.php
               |     |-- interfaces/UserRepository.php
               |-- Infrastructure
                     |-- Repository/MysqlUserRepository.php

配置是:

// composer.json

"autoload": {
    "psr-4": {
        "UserBundle\\": "src/Smartlink/UserBundle",
        "SmartlinkBundle\\": "src/Smartlink/SmartlinkBundle",
        "App\\": "src/"
    }
},

=================================================

// config/bundles.php

return [
    ...
    UserBundle\SmartlinkUserBundle::class => ['all' => true],
    SmartlinkBundle\SmartlinkSmartlinkBundle::class => ['all' => true],
];

=================================================

// config/services.yaml

services:
    _defaults:
        autowire: true      # Automatically injects dependencies in your services.
        autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

    UserBundle\:
        resource: '../src/Smartlink/UserBundle/'
        exclude:
            - '../src/Smartlink/UserBundle/Domain/Entity/'
    SmartlinkBundle\:
        resource: '../src/Smartlink/SmartlinkBundle/'
        exclude:
            - '../src/Smartlink/SmartlinkBundle/Domain/Entity/'
    App\:
        resource: '../src/'
        exclude:
            - '../src/DependencyInjection/'
            - '../src/Entity/'
            - '../src/Kernel.php'
            - '../src/Tests/'
            - '../src/Smartlink/'

=================================================

// config/routes/annotations.yaml

userbundle_controllers:
    resource: ../../src/Smartlink/UserBundle/Infrastructure/Controller
    type: annotation

smartlinkbundle_controllers:
    resource: ../../src/Smartlink/SmartlinkBundle/Infrastructure/Controller
    type: annotation

controllers:
    resource: ../../src/Controller/
    type: annotation

kernel:
    resource: ../../src/Kernel.php
    type: annotation

=================================================

// config/packages/doctrine.yaml

mappings:
        App:
            is_bundle: false
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App
        SmartlinkUserBundle:
            is_bundle: true
            type: annotation
            dir: 'Domain/Entity'
            alias: user_bundle
        SmartlinkSmartlinkBundle:
            is_bundle: true
            type: annotation
            dir: 'Domain/Entity'
            alias: smartlink_bundle

UserRepository 与生成 make:user 命令的相同,但名称空间除外,名称空间更改为namespace UserBundle\Infrastructure\Repository;并将名称更改为实现 UserRepository 接口的 MysqlUserRepository

实体 User 是

namespace UserBundle\Domain\Entity;

use UserBundle\Infrastructure\Repository\MysqlUserRepository;

/**
 * @ORM\Entity(repositoryClass=MysqlUserRepository::class)
 */
class User implements UserInterface
{
    ...

我一直在搜索,我发现的只是关于 symfony 2 和 symfony 4,我尝试了与询问的人相同的方法,但仍然无法生成捆绑包的迁移。我缺少什么?

编辑:我更改了一些配置并解决了 UserBundle 未找到或不活动的问题,但主要的迁移问题仍然存在


终于找到答案了,解决方案在文件中config/packages/doctrine.yaml

mappings:
    App:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Entity'
        prefix: 'App\Entity'
        alias: App
    SmartlinkUserBundle:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Smartlink/UserBundle/Domain/Entity'  # 'Domain/Entity'
        prefix: 'UserBundle\Domain\Entity'
        alias: UserBundle
    SmartlinkSmartlinkBundle:
        is_bundle: false
        type: annotation
        dir: '%kernel.project_dir%/src/Smartlink/SmartlinkBundle/Domain/Entity'
        prefix: 'SmartlinkBundle\Domain\Entity'
        alias: SmartlinkBundle

修复方法是将 in_bundle 设置为 false 目录:错了,所以我必须修复它 我添加了前缀,没有前缀就会出错。

现在它起作用了。

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

symfony 5.1 捆绑迁移导致没有要处理的映射信息 的相关文章

随机推荐

  • 在 WPF 应用程序中使用手写笔或手指按下触摸屏上的按钮时出现异常

    我有一个带有初始窗口的 WPF 应用程序 该窗口在启动时显示为闪屏 在启动过程中 有一个后台线程 我们可以通过单击启动屏幕中的按钮来取消该线程 使用鼠标并单击按钮取消时 这一切都可以正常工作 但是 如果我使用触摸屏单击此按钮 那么应用程序偶
  • PHP:如何获取相关文件的URL

    PHP 是否有一个本机函数可以返回使用相对路径声明的文件的完整 URL 我需要得到 http www domain com projects test img share jpg from img share jpg 到目前为止 我已经尝试
  • 在 Rust 中使用本地函数是否会对性能产生负面影响?

    我最近意识到我可以在 Rust 中创建本地函数 函数中的函数 似乎是清理代码而不污染文件函数空间的好方法 下面是我所说的本地函数与 外部 函数的小样本 fn main fn local plus x i64 y i64 gt i64 x y
  • htmlentities“无效的多字节序列”错误

    在尝试通过 PHP 的 htmlentities 函数运行字符串时 我在某些情况下收到 无效的多字节序列 错误 有没有办法在调用函数之前清理字符串以防止发生此错误 从 PHP 5 4 开始 您应该使用以下内容来正确转义输出 escapedS
  • python 函数内部定义的 locals() 不起作用[重复]

    这个问题在这里已经有答案了 考虑下面的代码 dct one 2 3 现在下面的工作 for key val in dct items locals key val print one Result 2 3 但是当我使用我真正想要的功能时却不
  • hook脚本中修改svn下的文件

    修改特定文件的最佳方法是什么 如果有 under我们在 post commit 中的存储库hook 例如 我想将校验和行附加到 somefile conf 文件 您可能想阅读本章 http svnbook red bean com en 1
  • ASP.NET - 存储临时文件

    我有一个网络表单 允许用户在我们的系统中开票时上传文件 上传是使用 ajax控件工具包 asyncFileUpload控件完成的 这个想法是将文件保存到临时目录中 并且仅在用户点击 提交 按钮时将它们保存到永久位置 我希望能够删除不再相关的
  • 是否可以通过 adb shell 启动活动并接收其响应? [复制]

    这个问题在这里已经有答案了 我知道你可以从任何应用程序启动任何导出的活动 via adb使用以下命令 am start n com myapp test TestActivity 使用 am start 命令还可以向活动发送额外的数据 我知
  • 无法解析程序集:“Java.Interop”

    当我尝试构建应用程序时 出现以下异常 C Program Files x86 MSBuild Xamarin iOS Xamarin iOS Common targets 681 3 错误 无法解析程序集 Java Interop 版本 0
  • 我需要将每 4 个 WordPress 帖子包装在一个 div 中

    我需要一个 div 来包装 WordPress 循环中的每四个帖子 所以它会像 div four posts div div four posts div 我当前的代码是这样的 div class wine section div
  • 从 C# 中的字符串中提取基本 URl?

    我目前正在开发一个使用 NET 1 1 框架的项目 但我陷入了困境 我有一个像 http www example com mypage default aspx http www example com mypage default asp
  • 访问 cpp-netlib http 服务器中的请求标头

    我已经开始使用开发 HTTP 服务器cpp netlib 稳定版本 0 10 1 并且从可用文档中我不确定如何访问服务器处理程序中的 HTTP 请求标头 我知道可以使用包装器来完成 如下所示 void operator async serv
  • 如何将特定类型的数组存储到我的设置文件中?

    由于某种原因 我似乎无法将我的类的数组存储到设置中 这是代码 var newLink new Link Properties Settings Default Links new ArrayList Properties Settings
  • 如何像 IN 语句一样使用 PowershellWhere-Object

    我有以下有效的代码 foreach db in svr Databases where object name eq testDB or name eq master or name eq model or name eq msdb wri
  • Python - 从网站抓取数据时重音字符的问题

    我是 Nicola 一名 Python 新用户 没有真正的计算机编程背景 因此 我确实需要一些帮助来解决我遇到的问题 我编写了一段代码来从此网页抓取数据 基本上 我的代码的目标是从页面中的所有表中抓取数据并将它们写入 txt 文件中 这里我
  • Amazon EC2 通过优雅关闭自动缩小规模?

    我们正在考虑使用 EC2 自动扩展来应对负载峰值 在我们的例子中 我们希望根据 SQS 队列大小来扩展实例 然后随着队列大小重新受到控制而缩小实例 每条 SQS 消息都定义了一个可能长时间运行的作业 有时每条消息长达 20 分钟 必须在实例
  • 使用 moment.js 获取该月的第一个工作日

    我有一些代码使用 moment js 这是一个要求 获取该月的第一个工作日 如下所示 dateStart function var first moment startOf month switch first day case 6 ret
  • 如何将 /etc/resolv.conf 下的自定义名称服务器添加到 pod 中?

    哪个服务在 pod 的 etc resolv conf 下分配名称服务器 通常应该从主机 etc resolv conf 获取 我在 pod 的 etc resolv conf 下看到不同的名称服务器 kbernetes 上是否有任何配置
  • Pandas / xlsxwriter writer.close() 没有完全关闭excel文件

    我试图在使用 python 脚本创建 Excel 文件后手动修改它 不幸的是 如果脚本仍在运行 则在尝试使用相同名称保存脚本时会出现共享文件冲突错误消息 代码中一切都运行顺利 文件已创建 填充并保存 我可以打开它并对其进行处理 但如果脚本仍
  • symfony 5.1 捆绑迁移导致没有要处理的映射信息

    我正在 DDD 下开发 Symfony 5 1 项目 因此我对所有默认文件夹进行了一些更改 我在 src 文件夹中有 2 个包 目前我只在其中一个包中有实体 我使用命令 make user 生成了实体用户及其存储库 然后移动文件并更改命名空