kayue / KayueWordpressBundle

A Symfony 2 bundle for providing WordPress repositories and authenticating users (login).
101 stars 43 forks source link

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

Open ZaneCEO opened 4 years ago

ZaneCEO commented 4 years ago

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 commented 4 years ago

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.