Symfony 4 Doctrine,从数据库创建实体 table

Symfony 4 Doctrine, creating Entities from database table

这里是 Symfony 的新手 我正在关注有关将数据库表映射到实体的 this 教程。我在我的数据库中创建了 blog_postblog_comment 表。 我试过 运行 这个 php bin/console doctrine:mapping:import --force AppBundle xml 吐出以下错误。

Bundle "AppBundle" does not exist or it is not enabled. Maybe you forgot to 
add it in the registerBundles() method of your App\Kernel.php file? 

我的 doctrine.yaml 几乎是开箱即用的。

Doctrine.yaml

doctrine:
dbal:
    # configure these for your database server
    driver: 'pdo_mysql'
    server_version: '5.7'
    charset: utf8mb4

    # With Symfony 3.3, remove the `resolve:` prefix
    url: '%env(resolve:DATABASE_URL)%'
orm:
    auto_generate_proxy_classes: '%kernel.debug%'
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping: true
    mappings:
        App:
            is_bundle: true
            type: annotation
            dir: '%kernel.project_dir%/src/Entity'
            prefix: 'App\Entity'
            alias: App

我在 src/Entity/ 下创建了 App.php Class 并在 bundles.php 下添加了一行,但仍然出现错误。我在 bundles.php 上添加的行是 App\Entity\App::class=>['all' => true], 因为那是我的 App.php class.

定义的命名空间

我得到的另一个错误是

PHP Fatal error:  Uncaught 
Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load 
class "App" from namespace "App\Entity\App".
Did you forget a "use" statement for another namespace? in 
/var/www/html/quick_tour/src/Kernel.php:32

中也发现了与我类似的情况。

自从 Symfony 4 使用 App 而不是 Appbundle

你必须在 Symfony 4 上使用 App 而不是 AppBundle