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

Bundle 'App' does not exist. #15

Closed
vertisan opened this issue Nov 1, 2020 · 3 comments · Fixed by #31
Closed

Bundle 'App' does not exist. #15

vertisan opened this issue Nov 1, 2020 · 3 comments · Fixed by #31
Labels
question Further information is requested

Comments

@vertisan
Copy link

vertisan commented Nov 1, 2020

Staring from Symfony 4, bundle conception has been rejected and is no longer used so how can I create mappings without it?

  • Symfony 5.1
  • ElasticSearch 7.1
  • This bundle 5.2.6.6

ongr_elasticsearch.yaml

ongr_elasticsearch:
    managers:
        default:
            index:
                index_name: book
                hosts:
                    - '%env(ELASTICSEARCH_URL)%'
            mappings:
                - App

services.yaml

services:
    _defaults:
        autowire: true
        autoconfigure: true
        bind:
            $manager: '@es.manager'

BookController.php

class BookController extends AbstractController
{
    /**
     * @Route("/book_popularity", methods={"GET"})
     */
    public function getPopularBooks(Request $request, Manager $manager)
    {
        $repo = $manager->getRepository(Book::class);
        $search = $repo->createSearch();

        $query = new TermQuery('title', 'Harry Potter');
        $search->addQuery($query);

        $result = $repo->findDocuments($search);

        return new JsonResponse($result);
    }
}

Book.php

/**
 * @ES\Document(type="ms_card_event")
 */
class Book
{
    /**
     * @ES\Property(type="text")
     */
    protected string $title;
    // constructor, getter & setterr
}

Without mapping I don't getting any results.

@alexander-schranz
Copy link
Member

alexander-schranz commented Dec 7, 2020

@vertisan you need to create a Bundle class inside your src folder else the bundle will not work:

// src/AppBundle.php

namespace App;

use Symfony\Component\HttpKernel\Bundle\Bundle;

class AppBundle extends Bundle {
}

and register this in your config/bundles.php.

       \App\AppBundle::class => ['all' => true],

@alexander-schranz alexander-schranz added the question Further information is requested label Dec 7, 2020
@pkly
Copy link

pkly commented Mar 20, 2021

I just hit the same issue while trying to convert our project using the ongr bundle from 7 to this one, as 300+ deprecation errors per request is a bit ridiculous.

It'd be nice if someone could implement this feature, some bundles already do it by asking for the name of the "bundle" to be "app" which is a reserved value and then just look at the src folder.

Seems like all changes required are in the DocumentFinder.php file.
I could probably work on this if you're unwilling to

@AndreasA
Copy link

AndreasA commented Sep 21, 2022

Using AppBundle like mentioned here #15 (comment) can result in other issues like e.g. Doctrine mappings not working correctly in combination with bundle auto mapping active.

I have now manually changed the argument for the document finder to include a the "AppBundle" only there, instead of using it with config/bundles.php that way it is only used/available for this bundle mappings. And I was also able to use App as namespace and the class name can be anything as long as it is directly in the src folder.

Not a perfect solution though.

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

Successfully merging a pull request may close this issue.

4 participants