Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot autowire: The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity #89

Open
ZaneCEO opened this issue Dec 24, 2019 · 1 comment

Comments

@ZaneCEO
Copy link

ZaneCEO commented Dec 24, 2019

Hi, I'm stuck in my Symfony 4.4.1 project.

This is my config:

// config/packages/kayue_wordpress.yaml

kayue_wordpress:
  connection: 'wordpress'
// config/packages/doctrine.yaml

doctrine:
    dbal:
        default_connection: default
        connections:
            default:
                url: '%env(resolve:DATABASE_URL)%'
                charset: utf8mb4
                default_table_options:
                    collate: utf8mb4_unicode_ci
            wordpress:
                url: '%env(resolve:DATABASE_URL_WORDPRESS)%'
                charset: utf8mb4
                default_table_options:
                    collate: utf8mb4_unicode_ci

    orm:
        auto_generate_proxy_classes: true
        default_entity_manager: default
        entity_managers:
            default:
                connection: default
                auto_mapping: true
                naming_strategy: doctrine.orm.naming_strategy.underscore
                mappings:
                    App:
                        is_bundle: false
                        type: annotation
                        dir: '%kernel.project_dir%/src/Entity'
                        prefix: 'App\Entity'
                        alias: App
            wordpress:
                connection: wordpress
                mappings:
                    KayueWordpressBundle:
                        is_bundle: true

Unfortunately I'm unable to get the repo:

<?php

namespace App\Service\WordPress;

use App\Traits\Foreachable;
use Doctrine\ORM\EntityManagerInterface;
use Kayue\WordpressBundle\Entity\Post;

class PostCollection implements \Iterator
{
    use Foreachable;

    protected $postRepository;

    public function __construct(EntityManagerInterface $entityManager)
    {
        $this->postRepository = $entityManager->getRepository(Post::class);
    }
}

I get:

The class 'Kayue\WordpressBundle\Entity\Post' was not found in the chain configured namespaces App\Entity.

I'm pretty sure my repo for WordPress is misconfigured, but I cannot understand how to fix it.

Thanks for you help, merry Christmas!

@ZaneCEO
Copy link
Author

ZaneCEO commented Dec 27, 2019

The solution is here: https://stackoverflow.com/a/59502316/1204976

Devs, please add this config file to the bundle so it can actually work with Symfony 4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant