我按照Sylius网站上的指南定制模型: http://docs.sylius.com/en/1.0/customization/model.html
当我跑步时:
php bin / console doctrine:schema:update --force
或 php bin / console doctrine:migrations:diff
错误:在链配置的命名空间中找不到类'AppBundle \ Entity \ Country'
添加的文件: \ SRC \的appbundle \实体\ Country.php \ SRC \的appbundle \资源\配置\教义\ Country.orm.yml
添加了:
sylius_addressing:
resources:
country:
classes:
model: AppBundle\Entity\Country
于: \应用\配置\ config.yml
和config.yml上的doctrine相关设置如下:
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
server_version: "5.5"
charset: UTF8
doctrine_migrations:
dir_name: "%kernel.root_dir%/migrations"
namespace: Sylius\Migrations
table_name: sylius_migrations
name: Sylius Migrations
Country.php
<?php
namespace AppBundle\Entity;
use Sylius\Component\Addressing\Model\Country as BaseCountry;
class Country extends BaseCountry
{
private $flag;
public function getFlag(): ?bool
{
return $this->flag;
}
public function setFlag(bool $flag): void
{
$this->flag = $flag;
}
}
(Windows 7上安装了Sylius 1.0) 尝试了清除缓存和许多其他方法,但没有线索。
答案 0 :(得分:0)
config.yml中有缩进错误,它应该是:
sylius_addressing:
resources:
country:
classes:
model: AppBundle\Entity\Country
(您还没有国家/地区之前的标签符号)
答案 1 :(得分:0)
谢谢,但只需再次检查,标签已经包含在内。
YAML禁止标签。请改用2或4个空格。见video
答案 2 :(得分:0)
我已经安装了最新版本(1.1.6)并且有效!
所以,应该是1.0.0版本的错误......