Sylius Product Bundle as dependency - symfony

I have an existing Symfony2 project which I'm attempting to install and use certain bundles from the Sylius project as dependencies. Here is my problem, I've added the SyliusProductBundle and all of its dependencies; however, when I attempt to update my database schema with:
app/console doctrine:scheme:update --force
I get the following error:
[Doctrine\Common\Persistence\Mapping\MappingException]
Class 'Sylius\Bundle\ProductBundle\Model\ProductInterface' does not exist
I'm not sure why this is happening, although it seems to be some sort of namespacing issue?
I have the following configuration:
sylius_resource:
resources:
src.user:
driver: doctrine/orm
templates: App:User
classes:
model: SRC\Bundle\UserBundle\Entity\User
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
form: Sylius\Bundle\CoreBundle\Form\Type\ProductType

Please register the bundle before DoctrineBundle. This is important as we use listeners which have to be processed first.

Related

How to generate document with Symfony 3.4 using Symfony flex

With Symfony flex, one of the change is that there is no default bundle when using the symfony/skeleton.
I don't find a way to use the command doctrine:mongodb:generate:documents in this context.
Could you please tell me how to use it ?
Exemple:
php bin\console doctrine:mongodb:generate:documents App
2018-02-17T18:35:22+00:00 [error] Error thrown while running command "doctrine:mongodb:generate:documents AppBundle --document Test". Message: "No bundle AppBundle was found."
In DoctrineODMCommand.php line 87:
No bundle AppBundle was found.
doctrine:mongodb:generate:documents [--document [DOCUMENT]] [--no-backup] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command> <bundle>
This is how I setup my project
composer create-project symfony/skeleton:3.4 test
composer config "platform.ext-mongo" "1.6.16" && composer require "alcaeus/mongo-php-adapter"
composer require doctrine/mongodb-odm-bundle
Thanks
Regards,
Chris
There is a similar issue with doctrine orm and doctrine:generate:entities. The Doctrine team discourages users from using these commands and therefore does no longer want to maintain them.
I think the easiest workaround I've seen so far is:
Create a Symfony 3.3 style application using the Symfony installer.
Generate the entities in the AppBundle as you did before
Change the namespace from AppBundle to App.
Move the files into your Symfony 4 project.
Some of the Symfony team also set out to provide similar code generation in a MakerBundle. As far as I can tell there is nothing for generating ODM-style entities, but you could open an issue or contribute something for this yourself.
For reference see: https://github.com/doctrine/DoctrineBundle/issues/729
The MongoDBBundle requires you have "Bundle" but with Symfony flex you are using FrameworkBundle and not "AppBundle" unless you created it before, I think you have not created it, so it tells you that it does not exist.
You can not use the "FrameworkBundle" either beacause FrameworkBundle have other namspace and other base path, so the command to generate the documents does not know where the files are.
After a lot of time figuring out how to diry-fix it:
Create custom Bundle inside your project (EX: AppCoreBundle)
Define custom mapping inside packages/doctrine_mongodb.yaml (change type value if you use xml or yaml)
doctrine_mongodb:
auto_generate_proxy_classes: '%kernel.debug%'
auto_generate_hydrator_classes: '%kernel.debug%'
connections:
default:
server: '%env(MONGODB_URL)%'
options: {}
default_database: '%env(MONGODB_DB)%'
document_managers:
default:
auto_mapping: true
mappings:
AppCoreBundle:
is_bundle: true
type: annotation
dir: '/Document'
prefix: App\CoreBundle\Document
alias: AppCoreBundle
Change the directory "src" to "App" to avoid issues then update psr-4 namaspace inside composer.json: "App\\": "App/"
Move all Documents to the Bundle Document directory and change package names.
You will also have to change ALL references to "src" directory in your project, for example in services.yaml.
Then execute: rm -rf var/cache/* && composer install to force to clear cache and refs.
Then execute: php bin/console doctrine:mongodb:generate:documents AppCoreBundle
Important!
This solution solves compatibility problems with MongoODMBundle with Symfony 4 but it is not a correct way. The right fix involves modifying the behavior of the bundle or Symfony 4.

The class sylius.model.product_archetype.class does not exist.

I am working on a Symfony 2 app and in the process of integrating the Sylius product bundle I get the following error when running
php app/console doctrine:schema:update --force
The error is
The class sylius.model.product_archetype.class does not exist.
Configuration
This is my confi.yml file
sylius_cart:
resolver: app.cart_item_resolver # The id of our newly created service.
classes: ~ # This key can be empty but it must be present in the configuration.
sylius_order:
driver: doctrine/orm # Configure the doctrine orm driver used in documentation.
sylius_money: ~
sylius_product:
driver: doctrine/orm
stof_doctrine_extensions:
orm:
default:
sluggable: true
timestampable: true
#sylius_archetype:
sylius_archetype:
driver: doctrine/orm # Configure the doctrine orm driver used in the documentation.
sylius_translation:
default_locale: en
And the bundles I have include are
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Sylius\Bundle\ProductBundle\SyliusProductBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
new Sylius\Bundle\VariationBundle\SyliusVariationBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\CartBundle\SyliusCartBundle(),
new Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
new Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
new Sylius\Bundle\ArchetypeBundle\SyliusArchetypeBundle(),
Any idea what I am doing wrong here. It seems that the docs does not match the code any more.
The core team is working hard to cleanup the documentation (see here), aiming to the 1.0 beta release.
It seems you require a lot of components from Sylius. What about starting from the standard edition and create you own bundle to change whatever you want ? The customization guide is freshly up to date (here).
Core config reference for product archetype is the following:
sylius_archetype:
resources:
product:
archetype:
classes:
model: Sylius\Component\Core\Model\Archetype
interface: Sylius\Component\Product\Model\ArchetypeInterface
translation:
classes:
model: Sylius\Component\Product\Model\ArchetypeTranslation
interface: Sylius\Component\Product\Model\ArchetypeTranslationInterface
subject: Sylius\Component\Core\Model\Product
attribute: Sylius\Component\Product\Model\Attribute
option: Sylius\Component\Product\Model\Option
You have to change, I guess
Sylius\Component\Core\Model\Archetype
by
Sylius\Component\Product\Model\Archetype
And
Sylius\Component\Core\Model\Product
by
Sylius\Component\Product\Model\Product
Hope this helps :)

EasyAdminBundle ReflectionException at create Backend section of install

Having an issue with the final stage of the setup of Easy Admin in a fresh Symfony 3 install,
at the "Your First Backend" : Creating the backend for those entities just require you to add the following configuration in the app/config/config.yml file:
# app/config/config.yml
easy_admin:
entities:
- AppBundle\Entity\Product
- AppBundle\Entity\Category
- AppBundle\Entity\User
When I do this I get error :
[ReflectionException] Class
AppBundle\Entity\Product does not exist
All the previous commands for setup installed without error, including installing the assets.
In documentation of EasyAdminBundle You have
Let's suppose that your Symfony application defines three Doctrine ORM entities called Product, Category and User.
In entities section you need to list already existing in your app Entities. If you don't have any - create it.
Docs: https://github.com/javiereguiluz/EasyAdminBundle/blob/master/Resources/doc/getting-started/2-first-backend.md

Sylius installing cart/orderBundle - service "sylius.translatable.listener" error

I'm trying to install only the cartBundle and orderBundle (with their dependencies) for my application. I'm still a newbie in sf2 so stop me if I'm wrong in my thinking.
So on packagist I found the lastest version :
"sylius/order-bundle": "0.14.*#dev"
But composer wouldn't install all the dependencies by itself (all the *#dev), so I had to manually add all of them to composer.json
After some time I finally got to the configuration of the bundles in app/config.yml and I added the bundles on top of appKernel.php.
But then I have this error :
ParameterNotFoundException in ParameterBag.php line 106: The service "sylius.translatable.listener" has a dependency on a non-existent parameter "sylius.translation.mapping". Did you mean this: "sylius.translation.default.mapping"?
I can't figure out what to do know. I probably missed something. I couldn't find the documentation for the translationBundle : http://docs.sylius.org/en/latest/bundles/SyliusTranslationBundle/index.html
If you have any idea, please let me know.
Thanks
just for curiosity:
i tried to use the
"sylius/taxonomy-bundle": "~0.13"
in my project and needed to manualy additonaly require
"sylius/translation-bundle": "~0.13",
"sylius/locale-bundle": "~0.13",
in symfony i also needed to add the bundles to the kernel:
new Sylius\Bundle\TaxonomyBundle\SyliusTaxonomyBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Sylius\Bundle\TranslationBundle\SyliusTranslationBundle(),
new Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(),
and
#app/config/config.yml
sylius_taxonomy:
driver: doctrine/orm
classes:
taxonomy: ~
taxonomy_translation: ~
taxon: ~
taxon_translation: ~
sylius_locale:
driver: doctrine/orm
and
#app/config/parameters.yml
sylius.translation.default.mapping:
translatable:
field: translations
currentLocale: currentLocale
fallbackLocale: fallbackLocale
translation:
field: translatable
locale: locale
sylius.locale: %locale%
sylius.context.locale: %locale%
maybe this will shorten the process for someone else..
Please check https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/Resources/config/app/sylius.yml#L239-L247.
I gues you should have similar section in your config.

entity manager not defined in sonata bundle

I have integrated sonata admin bundle. I then integrate sonata news bundle successfully . Then I created a custom bundle. I want to configure this bundle as my CMS bundle using sonata bundle. I am able to display my CMS bundle in admin section but when I try to to edit or add new item I am getting an error:
No entity manager defined for class Fcse\CmsBundle\Entity\Book 500
Internal Server Error - RuntimeException
Book is my entity when i run command
app/console doctrine:schema:update --force
Book table is also not creating. Am I missing something in configuration?
my config file is large. i am posting the code of my cms bundle.
fcse_cms:
title: Sonata Project
link: http://local.demo
description: Cool bundles on top of Symfony2
salt: 'secureToken'
class:
book: Fcse\CmsBundle\Entity\Book
admin:
book:
class: Fcse\CmsBundle\Admin\BookAdmin
controller: SonataAdminBundle:CRUD
translation: CmsBundle
doctrine:
orm:
entity_managers:
default:
#metadata_cache_driver: apc
#query_cache_driver: apc
#result_cache_driver: apc
mappings:
FcseCmsBundle: ~
and i import this file in app/config.yml.

Resources