![](/img/trans.png)
[英]Sylius Setup with PHP8: How can I setup a new project with the sylius-standard edition using the latest Sylius Core?
[英]How to reuse sylius components in another project?
最近,我了解了Sylius項目,並試圖在一個單獨的項目(僅研究)中重用其組件。
我的目標是測試是否可以在單獨的項目中使用sylius組件。 只有幾個組成部分。
按照文檔( http://sylius-older.readthedocs.io/en/latest/components/Order/basic_usage.html ),我能夠安裝組件並使用它們的類,但是我該如何處理數據庫表?
我安裝了該學說並試圖映射這些類,但是我做不到。
我正在考慮為每個表創建遷移(規則或雄辯的)並執行操作(CRUD)。
十分感謝大家。
假設您已經使用Composer安裝了OrderBundle,則可能必須告訴Doctrine在哪里讀取實體映射。 對於Sylius的OrderBundle,它們以xml文件的形式存儲在Resources / config / doctrine / models中,例如Order.orm.xml 。 如果查看DoctrineBundle食譜中的示例配置,則可以找到手動映射的參考。 在您的情況下,它可能看起來應該像這樣:
# app/config/config.yml (in Symfony 3.4)
# config/packages/doctrine.yaml (in Symfony 4)
doctrine:
dbal:
...
orm:
mappings:
SyliusOrderBundle:
is_bundle: false
type: xml
dir: '%kernel.project_dir%/../vendor/sylius/order-bundle/Resources/config/doctrine/models'
prefix: 'Sylius\Component\Order\Model'
alias: SyliusOrder
您可能需要對此進行調整,例如,如果您有Symfony 4應用程序,則可以使用默認的Doctrine命令來創建適當的架構。 您可能還需要調整auto_mapping
下doctrine.orm
並可能手動如果你這樣做映射自己的實體。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.