我正在尝试将Sylius Product Bundle集成到我现有的Symfony项目中。它已经配置了学说。
这是我得到的错误:
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
The child node "driver" at path "sylius_attribute" must be configured.
知道是什么导致了这个吗?我没有做任何其他的sylius安装,而是直接按照指示操作。
http://docs.sylius.org/en/latest/bundles/SyliusProductBundle/installation.html
我必须在composer.json文件中更改doctrine-bundle版本以允许
作曲家需要“sylius / product-bundle”
成功运行且没有错误。我将版本从1.2。*更改为
“doctrine / doctrine-bundle”:“1.3。*”
在作曲家安装这些人之后,我将以下内容添加到我的config.yml文件
sylius_product:
driver: doctrine/orm
classes:
product:
model: Sylius\Bundle\CoreBundle\Model\Product
controller: Sylius\Bundle\CoreBundle\Controller\ProductController
repository: Sylius\Bundle\CoreBundle\Repository\ProductRepository
stof_doctrine_extensions:
default_locale: es_us
translation_fallback: true
orm:
default:
tree: true
最初我收到以下错误:
[Exception]
Missing parameter sylius.translation.default.mapping. Default translation mapping must be defined!
经过一番搜索后,我将下面的部分添加到config.yml文件
sylius_translation:
default_mapping:
translatable:
field: translations
currentLocale: currentLocale
fallbackLocale: fallbackLocale
translation:
field: translatable
locale: locale
早在我的config.yml文件中已经存在:
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
我没有在这些设置中更改任何内容。
我在这里做错了什么或错过了什么?非常感谢您的帮助。
谢谢!
修改
我尝试添加以下所有项目:
sylius_attribute:
driver: doctrine/orm
sylius_variation:
driver: doctrine/orm
sylius_archetype:
driver: doctrine/orm
现在我收到以下错误:
[InvalidArgumentException]
The class sylius.model.product_archetype.class does not exist.
我将相应的文件添加到AppKernel但仍然没有运气!
new Sylius\Bundle\AttributeBundle\SyliusArchetypeBundle(),
然后将其更改为:
new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
到目前为止,设置Sylius一直很紧张:(
答案 0 :(得分:3)
我已经updated the docs了解了ProductBundle:
在composer.json
中,您需要添加以下行:
"require": {
...
"sylius/locale-bundle": "0.13.*",
"sylius/product-bundle": "0.13.*"
...
}
在app/AppKernel.php
:
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
new Sylius\Bundle\ProductBundle\SyliusProductBundle(),
new Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\VariationBundle\SyliusVariationBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
在config.yml
:
parameters:
sylius.locale: "%locale%"
sylius_archetype:
classes:
product:
subject: Sylius\Component\Product\Model\Product
attribute: Sylius\Component\Product\Model\Attribute
option: Sylius\Component\Product\Model\Option
archetype:
model: Sylius\Component\Product\Model\Archetype
repository: Sylius\Bundle\ResourceBundle\Doctrine\ORM\TranslatableEntityRepository
translatable:
targetEntity: Sylius\Component\Product\Model\ArchetypeTranslation
archetype_translation:
model: Sylius\Component\Product\Model\ArchetypeTranslation
sylius_attribute:
driver: doctrine/orm
sylius_product:
driver: doctrine/orm
sylius_locale:
driver: doctrine/orm
sylius_translation:
default_mapping:
translatable:
field: translations
currentLocale: currentLocale
fallbackLocale: fallbackLocale
translation:
field: translatable
locale: locale
sylius_variation:
driver: doctrine/orm
stof_doctrine_extensions:
orm:
default:
sluggable: true
timestampable: true
现在您应该能够成功运行架构更新
$ php app/console doctrine:schema:update --dump-sql
如果满意,执行:
$ php app/console doctrine:schema:update --force
更新:升级到0.14时此配置会中断(当前发布的版本为0.13)。
答案 1 :(得分:1)