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.

3 Answers 3

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)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, but just check again, the tab already included. Any other ideas?
0

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

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

7 Comments

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
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?
Added on the original post, pls have a look.
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...
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).
|
0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.