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

Fail to install #952

Open
yo1nick opened this issue Jun 18, 2020 · 5 comments
Open

Fail to install #952

yo1nick opened this issue Jun 18, 2020 · 5 comments

Comments

@yo1nick
Copy link

yo1nick commented Jun 18, 2020

I try to install this bundle on windows using Symfony 4.4 and I receive this error:
Class App\src\Kernel does not exist in MappingPass.php line 65:

@bogdaniel
Copy link

bogdaniel commented Jul 6, 2020

Have you managed to install it ? If it's an yes can you provide the solution? Thanks

@yo1nick
Copy link
Author

yo1nick commented Jul 6, 2020

You can say that, I managed to get rid of the error in question, this is what I have done:
step 1: from composer remove
"post-install-cmd": [ "@auto-scripts" ], "post-update-cmd": [ "@auto-scripts" ]
step 2: run composer require ongr/elasticsearch-bundle
step 3: put back post-install and post-update
step 4: edit vendor/ongr/elasticsearch-bundle/DependencyInjection/Compiler/MappingPass.php
I've made 2 changes to that file first in private function getFullNamespace($filename) I add trim to preg_match like that:
preg_match('/^namespace (.*);$/', trim($namespaceLine), $match);
and the second change is in private function getClassname($filename) I replace $directoriesAndFilename = explode('/', $filename); with $directoriesAndFilename = explode(DIRECTORY_SEPARATOR, $filename);

Hope that helps you!

@bogdaniel
Copy link

bogdaniel commented Jul 7, 2020

Thank you I will try it.

LE: It Worked smooth the way you did it :-) thank you for the fix but I encountered another problem.
After looking over the issues and everything I finally made it to work with the following changes

#899
#952

    private function getFullNamespace($filename)
    {
        $lines = preg_grep('/^namespace /', file($filename));
        $namespaceLine = array_shift($lines);
        $match = array();
        preg_match('/^namespace (.*);$/', trim($namespaceLine), $match);
        $fullNamespace = array_pop($match);

        return $fullNamespace;
    }

    private function getClassname($filename)
    {
        $directoriesAndFilename = explode(DIRECTORY_SEPARATOR, $filename);
        $filename = array_pop($directoriesAndFilename);
        $nameAndExtension = explode('.', $filename);
        $className = array_shift($nameAndExtension);

        return $className;
    }

@mjvanmiddelaar
Copy link

mjvanmiddelaar commented Jul 27, 2020

See also #958

you could also add something similar to:

ongr_elasticsearch:
    source_directories: [/src/Document]

in packages/ongr_elasticsearch.yaml

@Orest983
Copy link

Orest983 commented Dec 3, 2021

MappingPass.php

function getFullNamespace
line 169: preg_match('/^namespace (.*);$/', $namespaceLine, $match);

$namespaceLine - in some cases is a string with '\r\n' at the end, for example "namespace App\Twig;\r\n"
thus preg_match returns null, that causes an error "In MappingPass.php line 65: Class \AppExtension does not exist"

It isn't right, but I solved this problem by wrapping the argument into a function rtrim($namespaceLine)

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

4 participants