Задать вопрос
@zzmaster

Почему Symfony 6.2 не создает entity?

Я новичок в Симфони, но вроде тут негде сделать ошибку, иду по мануалу.
Собрался создать entity Result и успел ввести только имя сущности:

admin@$ bin/console make:entity

 Class name of the entity to create or update (e.g. AgreeableGnome):
 > Result

 created: src/Entity/Result.php
 created: src/Repository/ResultRepository.php


 [ERROR] Only attribute mapping is supported by make:entity, but the <info>App\Entity\Result</info> class
         uses a different format. If you would like this command to generate the properties &
         getter/setter methods, add your mapping configuration, and then re-run this command with the
         <info>--regenerate</info> flag.


Что тут за беда?

Попытка запуска с regenerate

$ bin/console make:entity --regenerate

 This command will generate any missing methods (e.g. getters & setters) for a class or all classes in a
 namespace.

 To overwrite any existing methods, re-run this command with the --overwrite flag

 Enter a class or namespace to regenerate [App\Entity]:
 > Results



 [ERROR] No entities were found in the "Results" namespace.


composer.json
{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": ">=8.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "ext-mysql": "*",
        "ext-intl": "*",
        "ext-mbstring": "*",
        "composer/package-versions-deprecated": "^1.11",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^2.1",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.10",
        "eightpoints/guzzle-bundle": "^8.2",
        "phpdocumentor/reflection-docblock": "^5.3",
        "phpstan/phpdoc-parser": "^1.2",
        "symfony/console": "6.2.*",
        "symfony/dotenv": "6.2.*",
        "symfony/flex": "^2.2",
        "symfony/framework-bundle": "6.2.*",
        "symfony/mailer": "6.2.*",
        "symfony/messenger": "6.2.*",
        "symfony/notifier": "6.2.*",
        "symfony/process": "6.2.*",
        "symfony/property-access": "6.2.*",
        "symfony/property-info": "6.2.*",
        "symfony/serializer": "6.2.*",
        "symfony/twig-bundle": "6.2.*",
        "symfony/validator": "6.2.*",
        "symfony/yaml": "6.2.*",
        "twig/cssinliner-extra": "^3.0",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/inky-extra": "^3.0",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.48",
        "symfony/stopwatch": "^6.2",
        "symfony/web-profiler-bundle": "^6.2"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "symfony/flex": true
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "6.2.*"
        }
    }
}
  • Вопрос задан
  • 417 просмотров
Подписаться 1 Простой 1 комментарий
Решения вопроса 1
myks92
@myks92
Нашёл решение — пометь вопрос ответом!
Там где mappings сущностей замените тип аннотация на атрибут. type: annotation -> type: attribute

orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    auto_mapping: true
    mappings:
        App:
            is_bundle: false
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App
            type: attribute <— ТУТ
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы