Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make:entity Only attribute mapping is supported by make:entity #1156

Closed
JulienDupontDev opened this issue Jul 22, 2022 · 0 comments
Closed

Comments

@JulienDupontDev
Copy link

JulienDupontDev commented Jul 22, 2022

I have this issue which came from nowhere. To be clear I used make:entity to create all my entities since the beggening and they were all made with annotations. Now it's asking for attribute which I don't want at all. If I change doctrine.yaml mapping to attribute it works but that's not the solution since my others entities use annotations.

[ERROR] Only attribute mapping is supported by make:entity, but the App\Entity\Test 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 --regenerate flag.

I have this issue since today and i don't know what caused it. Can't seem to find anyone with this issue neither :/

My composer json

{ "type": "project", "license": "proprietary", "minimum-stability": "stable", "prefer-stable": true, "require": { "php": ">=8.0", "ext-ctype": "*", "ext-iconv": "*", "aws/aws-sdk-php": "^3.209", "aws/aws-sdk-php-symfony": "^2.2", "beberlei/doctrineextensions": "^1.3", "composer/package-versions-deprecated": "~1.11.99.4", "doctrine/annotations": "^1.13", "doctrine/doctrine-bundle": "^2.5", "doctrine/doctrine-migrations-bundle": "^3.2", "doctrine/orm": "^2.10", "easycorp/easyadmin-bundle": "^4.0", "firebase/php-jwt": "^6.1", "friendsofsymfony/rest-bundle": "^3.3", "jms/serializer": "^3.17", "jms/serializer-bundle": "^4.0", "lexik/jwt-authentication-bundle": "~2.14.4", "nelmio/api-doc-bundle": "^4.9", "nelmio/cors-bundle": "^2.2", "oneup/flysystem-bundle": "^4.3", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpdoc-parser": "^1.2", "sensio/framework-extra-bundle": "^6.1", "symfony/apache-pack": "^1.0", "symfony/asset": "5.4.*", "symfony/console": "5.4.*", "symfony/dotenv": "5.4.*", "symfony/expression-language": "5.4.*", "symfony/flex": "^1.17|^2", "symfony/form": "5.4.*", "symfony/framework-bundle": "5.4.*", "symfony/http-client": "5.4.*", "symfony/intl": "5.4.*", "symfony/mailer": "5.4.*", "symfony/messenger": "5.4.*", "symfony/mime": "5.4.*", "symfony/monolog-bundle": "^3.1", "symfony/notifier": "5.4.*", "symfony/process": "5.4.*", "symfony/property-access": "5.4.*", "symfony/property-info": "5.4.*", "symfony/proxy-manager-bridge": "5.4.*", "symfony/runtime": "^6.0", "symfony/security-bundle": "5.4.*", "symfony/sendinblue-mailer": "5.4.*", "symfony/serializer": "5.4.*", "symfony/string": "5.4.*", "symfony/translation": "5.4.*", "symfony/twig-bundle": "5.4.*", "symfony/validator": "5.4.*", "symfony/web-link": "5.4.*", "symfony/yaml": "5.4.*", "tattali/mobile-detect-bundle": "^2.2", "twig/extra-bundle": "^2.12|^3.0", "twig/twig": "^2.12|^3.0", "vich/uploader-bundle": "^1.19", "zircote/swagger-php": "^4.4" }, "require-dev": { "ext-xdebug": "^3.1.0", "doctrine/doctrine-fixtures-bundle": "^3.4", "phpunit/phpunit": "^9.5", "symfony/browser-kit": "5.4.*", "symfony/css-selector": "5.4.*", "symfony/debug-bundle": "5.4.*", "symfony/maker-bundle": "^1.36", "symfony/phpunit-bridge": "^6.0", "symfony/stopwatch": "5.4.*", "symfony/web-profiler-bundle": "5.4.*" }, "config": { "allow-plugins": { "symfony/flex": true, "symfony/runtime": true }, "optimize-autoloader": true, "preferred-install": { "*": "dist" }, "sort-packages": true }, "autoload": { "psr-4": { "App\\": "src/" } }, "autoload-dev": { "psr-4": { "App\\Tests\\": "tests/" } }, "replace": { "symfony/polyfill-ctype": "*", "symfony/polyfill-iconv": "*", "symfony/polyfill-php72": "*" }, "scripts": { "auto-scripts": { "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, "post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ], "compile": [ "php bin/console doctrine:migrations:migrate --no-interaction --allow-no-migration" ] }, "conflict": { "symfony/symfony": "*" }, "extra": { "symfony": { "allow-contrib": true, "require": "5.4.*" } } }

doctrine.yaml

`doctrine:
dbal:
    url: '%env(resolve:DATABASE_URL)%'

    # IMPORTANT: You MUST configure your server version,
    # either here or in the DATABASE_URL env var (see .env file)
    #server_version: '13'
orm:
    auto_generate_proxy_classes: true
    naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
    auto_mapping: true
    mappings:
        App:
            is_bundle: false
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App`

I've seen a lot of people have the opposite issue where the error says "Only annotations", but not my case.

Here is the code from the failed entity created by doctrine

   `<?php

namespace App\Entity;

use App\Repository\TestRepository;
use Doctrine\ORM\Mapping as ORM;

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
    #[ORM\Id]
    #[ORM\GeneratedValue]
    #[ORM\Column()]
    private ?int $id = null;

    public function getId(): ?int
    {
        return $this->id;
    }
}`

Thank you for you help I really need this running now cause this school project is due next week :/

[EDIT] duplicate of #1152

fixed my issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant