Symfony 学说:构建模型错误

发布于 2024-10-01 01:19:13 字数 2176 浏览 0 评论 0原文

我已经为我的 Symfony+doctrine 应用程序编写了数据库的 yaml 模式,并且我试图让它来制作模型等,但它在 doctrine:build-model 上出错

$> ./symfony 学说:构建模型
>>>学说生成模型类

>>文件+ /tmp/doctrine_schema_89653.yml

 在 /tmp/doctrine_schema_89653.yml 中找不到 yml 模式

我将我的模式放入 config/doctrine/schema.yml 中,根据我所经历的所有教程,它应该位于其中。经过一番谷歌搜索后,我认为我的 yaml 中可能存在语法错误,但我不确定。这是以防万一:

Coder:
    actAs: [Timestampable]
    tableName: dormcode_coder
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        username: string(60)
        password: string(60)
        email: string(255)
        firstname: string(60)
        lastname: string(60)
        
Client:
    actAs: [Timestampable]
    tableName: dormcode_client
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        username: string(60)
        password: string(60)
        email: string(255)
        firstname: string(60)
        lastname: string(60)

Project:
    actAs: [Timestampable]
    tableName: dormcode_project
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        client_id: integer
        title: string(255)
        briefdesc: clob
        spec: clob
        coder_id: 
            type: integer
            notnull: false
            default: null
        paytype: string(30)
        negotiable: 
            type: bool
            default: false
        complete: 
            type: bool
            default: false
    relations:
        Coder:
            foreignType: one
        Client:
            foreignType: one

Iteration:
    actAs: [Timestampable]
    tableName: dormcode_iteration
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        ordernum: integer
        description: clob
        project_id: integer
    relations:
        Project:
            foreignAlias: Iterations

我不确定还会有什么,有谁知道其他什么类型的事情可能会导致该错误?这实际上没有意义...

编辑:我只是在 /tmp 中查找该文件,它就在那里。它继续 { } 就是这样。

I have written my yaml schema for the database for my Symfony+doctrine application, and I'm trying to get it to make the models and such, but it errors on doctrine:build-model

$> ./symfony doctrine:build-model
>> doctrine generating model classes

>> file+ /tmp/doctrine_schema_89653.yml

   No yml schema found in /tmp/doctrine_schema_89653.yml

I put my schema in config/doctrine/schema.yml, where it should be according to all the tutorials I have gone through. After some googling I think there might be a syntax error in my yaml, but I am not sure. Here it is just in case:

Coder:
    actAs: [Timestampable]
    tableName: dormcode_coder
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        username: string(60)
        password: string(60)
        email: string(255)
        firstname: string(60)
        lastname: string(60)
        
Client:
    actAs: [Timestampable]
    tableName: dormcode_client
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        username: string(60)
        password: string(60)
        email: string(255)
        firstname: string(60)
        lastname: string(60)

Project:
    actAs: [Timestampable]
    tableName: dormcode_project
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        client_id: integer
        title: string(255)
        briefdesc: clob
        spec: clob
        coder_id: 
            type: integer
            notnull: false
            default: null
        paytype: string(30)
        negotiable: 
            type: bool
            default: false
        complete: 
            type: bool
            default: false
    relations:
        Coder:
            foreignType: one
        Client:
            foreignType: one

Iteration:
    actAs: [Timestampable]
    tableName: dormcode_iteration
    columns:
        id:
            type: integer
            primary: true
            autoincrement: true
        ordernum: integer
        description: clob
        project_id: integer
    relations:
        Project:
            foreignAlias: Iterations

I'm not sure what else there would be, does anyone know what other kinds of things might cause that error? It doesn't really make sense...

EDIT: I just looked in /tmp for the file, and it is there. it contins { } and thats it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小糖芽 2024-10-08 01:19:13

是的,最近也犯了同样的错误,很麻烦。它所做的是尝试加载旧的临时文件,而不是您希望它使用的文件:

“在 /tmp/doctrine_schema_89653.yml 中找不到 yml 架构”

找到此临时文件夹(我我正在 Windows 上运行 XAMPP,所以我的位于 XAMPP 文件夹中),从那里删除所有旧架构文件,然后再次构建。您可能需要重复执行此操作,因为每次都会创建一个临时文件。

Yeah, had the same error recently, a nuisance. What it's doing is that it's trying to load an old temp file instead of the one you want it to use:

"No yml schema found in /tmp/doctrine_schema_89653.yml"

Find this temp file folder (I'm running XAMPP on Windows so mine was in the XAMPP folders), erase all old schema files from there, and build again. You may need to do this repeatedly, as a temp file is created every time.

江城子 2024-10-08 01:19:13

我看到你的 schema.yml 设置了 4 个空格作为缩进。我的总是有2个空格。你可以尝试一下。

我还从 lib 文件夹中删除了所有生成的类(例如 /lib/models/doctrine/* 和表单(不是 BaseForm.class.php)和过滤器,因为 symfony 首先生成模型并从那里生成 sql,然后插入数据库中的sql。

I see your schema.yml has set 4 spaces as indentation. Mine always has 2 spaces. You could try that.

I also deleted all generated classes from the lib folder (eg. /lib/models/doctrine/* and forms (not the BaseForm.class.php) and filters, because symfony first generates the models and from there the sql and then inserts the sql in the db.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文