Open yo1nick opened 4 years ago
Have you managed to install it ? If it's an yes can you provide the solution? Thanks
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!
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
https://github.com/ongr-io/ElasticsearchBundle/issues/899 https://github.com/ongr-io/ElasticsearchBundle/issues/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;
}
See also #958
you could also add something similar to:
ongr_elasticsearch:
source_directories: [/src/Document]
in packages/ongr_elasticsearch.yaml
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)
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: