1

I am trying to create entities but I have an error, the entity is created in the project but nothing created in the database.

Here is the error message: error message

and this is the generated Class

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
    * @ORM\Entity(repositoryClass="App\Repository\CategoryRepository")
*/
class Category
{
    /**
        * @ORM\Id()
        * @ORM\GeneratedValue()
        * @ORM\Column(type="integer")
    */
    private $id;

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

and this is my doctrine.yaml

doctrine:
   dbal:
    # configure these for your database server

    driver: 'pdo_mysql'
    server_version: '8.0.18'
    charset: utf8mb4
    host: 127.0.0.1
    port: 3306
    user: 'root'
    password: 'root'
    dbname: 'omega'
    #   dbname: '%env(DATABASE_NAME)%'
4
  • Can you please post an entity? Commented Feb 19, 2020 at 15:39
  • Can you please post your config/packages/doctrine.yaml ? Commented Feb 19, 2020 at 15:54
  • @Clarity edited Commented Feb 19, 2020 at 16:00
  • @shaax i have edit it Commented Feb 19, 2020 at 16:02

1 Answer 1

1

Try to add this at the end of your doctrine.yaml :

    orm:
        auto_generate_proxy_classes: true
        naming_strategy: doctrine.orm.naming_strategy.underscore
        auto_mapping: true
        mappings:
            App:
                is_bundle: false
                type: annotation
                dir: '%kernel.project_dir%/src/Entity'
                prefix: 'App\Entity'
                alias: App

Then retry. Let us know.

Sign up to request clarification or add additional context in comments.

1 Comment

It worked in the project thank you so much, but still the problem in the database because it wasn't created as in the project, am I missing something ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.