gpt4 book ai didi

php - Symfony 4 版本 :entity --regenerate fail with: No entities were found in the "App" namespace

转载 作者:行者123 更新时间:2023-12-01 16:15:46 27 4
gpt4 key购买 nike

来自composer.json

{
"name": "symfony/website-skeleton",
"type": "project",
"license": "MIT",
"description": "A skeleton to start a new Symfony website",
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "^4.0",
"symfony/console": "^4.0",
"symfony/expression-language": "^4.0",
"symfony/flex": "^1.0",
"symfony/form": "^4.0",
"symfony/framework-bundle": "^4.0",
"symfony/lts": "^4@dev",
"symfony/monolog-bundle": "^3.1",
"symfony/orm-pack": "^1.0",
"symfony/process": "^4.0",
"symfony/security-bundle": "^4.0",
"symfony/serializer-pack": "*",
"symfony/swiftmailer-bundle": "^3.1",
"symfony/translation": "^4.0",
"symfony/twig-bundle": "^4.0",
"symfony/validator": "^4.0",
"symfony/web-link": "^4.0",
"symfony/webpack-encore-pack": "*",
"symfony/yaml": "^4.0"
},
"require-dev": {
"symfony/browser-kit": "^4.0",
"symfony/css-selector": "^4.0",
"symfony/debug-pack": "*",
"symfony/dotenv": "^4.0",
"symfony/maker-bundle": "^1.5",
"symfony/phpunit-bridge": "^4.0",
"symfony/profiler-pack": "*",
"symfony/web-server-bundle": "^4.0"
},
"config": {
"preferred-install": {
"*": "dist"
},
"sort-packages": true
},
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"App\\Tests\\": "tests/"
}
},
"replace": {
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php71": "*",
"symfony/polyfill-php70": "*",
"symfony/polyfill-php56": "*"
},
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install --symlink --relative %PUBLIC_DIR%": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
},
"conflict": {
"symfony/symfony": "*"
},
"extra": {
"symfony": {
"allow-contrib": false
}
}
}

来自doctrine.yaml:

# /config/packages/doctrine.yaml
doctrine:
dbal:
default_connection: training
connections:
training:
dbname: "training"
driver: "pdo_mysql"
host: "localhost"
port: "3306"
user: "userdb"
password: "XXXXXXXXXX"
charset: UTF8
mapping_types:
bit: boolean
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: training
entity_managers:
training:
connection: training
auto_mapping: true

命令:

php bin/console doctrine:mapping:import --em=training App\Entity annotation --path=src/Entity

Course.php实体生成到src/Entity中:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
* Course
*
* @ORM\Table(name="course", indexes={@ORM\Index(name="id_product_idx_1", columns={"id_product"}), @ORM\Index(name="enabled_idx_1", columns={"enabled"}), @ORM\Index(name="sort_idx_1", columns={"sort"})})
* @ORM\Entity
*/
class Course
{
....

运行到控制台后:

php bin/console make:entity --regenerate App

此操作失败并出现错误:

No entities were found in the "App" namespace

同样

php bin/console make:entity --regenerate App\Entity 

如果我尝试

php bin/console make:entity --regenerate App\Entity\Course

输出为

Could not find Doctrine metadata for "App\Entity\Course". Is it mapped as an entity?

我做错了什么?

最佳答案

就我而言,这是因为我写道:

php bin/console make:entity --regenerate App\Entity\Course

而不是(注意双反斜杠)

php bin/console make:entity --regenerate App\\Entity\\Course

关于php - Symfony 4 版本 :entity --regenerate fail with: No entities were found in the "App" namespace,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50605365/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com