0

I followed the guideline on Sylius site for customizing models: http://docs.sylius.com/en/1.0/customization/model.html

When I run:

php bin/console doctrine:schema:update --force

or php bin/console doctrine:migrations:diff

Error: The class 'AppBundle\Entity\Country' was not found in the chain configured namespaces

Files added at: \src\AppBundle\Entity\Country.php \src\AppBundle\Resources\config\doctrine\Country.orm.yml

Added:

sylius_addressing:
    resources:
        country:
            classes:
                model: AppBundle\Entity\Country

at: \app\config\config.yml

And doctrine related settings on config.yml as below:

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;
  }
}

(Sylius 1.0 installed on Windows 7) Tried clear cache and many other methods but no clues.

Code
  • 71
  • 9

3 Answers3

0

You have an indentation error in config.yml, it should be: sylius_addressing: resources: country: classes: model: AppBundle\Entity\Country

(you haven't tab symbol before country)

Dr.X
  • 853
  • 9
  • 15
0

Thanks, but just check again, the tab already included.

YAML forbid tabs. Use 2 or 4 spaces instead. See here

yaroslavche
  • 383
  • 1
  • 9
  • Doctrine doesn't know anything about your Country Entity. Check identation in config.yml for doctrine. I try to reproduce the error on latest Sylius (1.1) following the guide and all working for me. Check my config on [pastebin](https://pastebin.com/Sn2VuBFY) – yaroslavche May 18 '18 at 09:26
  • 1
    And can you show your `src/AppBundle/Entity/Country.php` file? Is `Country` class extends `Sylius\Component\Addressing\Model\Country` and in `AppBundle\Entity` namespace? – yaroslavche May 18 '18 at 09:38
  • Added on the original post, pls have a look. – Code May 21 '18 at 01:35
  • compared the config, no big diff except: resource: "%kernel.root_dir%/config/routing.yml" dir_name: "%kernel.root_dir%/migrations" Tried changed to yours and no different... – Code May 21 '18 at 01:45
  • Try this command: `composer dump-autoload`. If it doesn't help - IDK and need to look at the files as is. Because according to this description everything works (at least for me). – yaroslavche May 22 '18 at 08:02
  • checked on config again, no: - { resource: services.yml } (and no such file as well) not sure if it's the different between 1.0.0 and 1.1 version. – Code May 23 '18 at 02:08
  • I have installed latest version (1.1.6) and it works! So, should be a bug on 1.0.0 version... I thought 1.0.0 would be a stable version so I picked it. Now I've found I was wrong... Anyway, thanks for your help indeed. – Code May 23 '18 at 03:42
0

I have installed latest version (1.1.6) and it works!

So, should be a bug on 1.0.0 version...

Code
  • 71
  • 9