conjecto / nemrod

Nemrod is a framework providing an abstraction layer for handling (consuming and producing) RDF in a Symfony2 project
http://conjecto.github.io/nemrod
Other
23 stars 6 forks source link

Notice: Undefined index: indexes #8

Closed NadaBen closed 8 years ago

NadaBen commented 8 years ago

Hello, please i need some help, when i update my composer and i try to clear the catch it gives me this error : 1/ ContextErrorException in ElasticaFramingRegistrationPass.php line 28: Notice: Undefined index: indexes,

2/at ErrorHandler->handleError('8', 'Undefined index: indexes', 'C:\wamp\www\test\vendor\conjecto\nemrod\src\Conjecto\Nemrod\Bundle\ElasticaBundle\DependencyInjection\CompilerPass\ElasticaFramingRegistrationPass.php', '28', array('container' => object(ContainerBuilder), 'config' => array(), 'jsonLdFrameLoader' => object(JsonLdFrameLoader))) in ElasticaFramingRegistrationPass.php line 28

line 28 of ElasticaFramingRegistrationPass.php is as follows: foreach ($config['indexes'] as $name => $types) {

how to solve that please ?

conjectwan commented 8 years ago

Hello,

Have you create an elastica block in your config.yml ? You have an example in our demo project demo project. The error is surely caught when the composer rebuild the application cache. And Nemrod read the config.yml file during the cache compilation.

If you does not want to work with elasticsearch, you can also remove the ElasticaBundle from the AppKernel.

I hope it will solve your problem. If not, do not hesitate to ask us some help again ;-)

NadaBen commented 8 years ago

solved when i removed elasticsearch,, but if i use elasticsearch with the demo project it gives me this error Twig_Error_Loader in unable to find frame have you any idea about that ?

conjectwan commented 8 years ago

Nemrod use JsonLD frames to serialize RDF resources. So, it is used for elasticsearch serialization.

If we read the config.yml file in the demo project, we can see a frame: "@Demo/Laureate/laureate.jsonld"

A such path will search a frame in DemoBundle/Resources/frames/Laureate/laureate.jsonld. Maybe this frame does not exist in your project ?

NadaBen commented 8 years ago

i did that , same error

conjectwan commented 8 years ago

Did you try a cache:clear ?

NadaBen commented 8 years ago

when i clear my cache it gives me [Twig_Error_Loader] Unable to find frame "@Photos/PhotoResource/PhotoResource.jsonld".

NadaBen commented 8 years ago

this is my class resource `<?php

namespace TestTask\PhotosBundle\RdfResource;

use Conjecto\Nemrod\Resource as BaseResource; use Conjecto\Nemrod\ResourceManager\Annotation\Resource; use Conjecto\Nemrod\ResourceManager\Annotation\Property; use Conjecto\Nemrod\Framing\Annotation as Serializer;

/**

the file PhotoResource.jsonld is in TestTask\PhotosBundle\Resources\PhotoResource

and my configuration is as follows : `elastica: clients: default: host: %elasticsearch_host% port: %elasticsearch_port%

indexes: PhotoResource: client: default settings: index: analysis: analyzer: en: tokenizer: standard types: PhotoResource: type: "terms:PhotoResource" frame: "@Photos/PhotoResource/PhotoResource.jsonld"`

conjectwan commented 8 years ago

If you remove the line @Serializer\JsonLd(frame="@Photos/PhotoResource/PhotoResource.jsonld"), does the problem persist ?

NadaBen commented 8 years ago

yes the same error

NadaBen commented 8 years ago

is he has a relationship with the twig files ??

conjectwan commented 8 years ago

No but we use the twig file finder to get frame files

NadaBen commented 8 years ago

yes so do you have any other idea ?

conjectwan commented 8 years ago

Yes there is a problem with the frame path. I'm searching the corresponding code in Nemrod to guide you find the searched path.

NadaBen commented 8 years ago

Ok i'm waiting for your response, thank you

conjectwan commented 8 years ago

You can go to Twig_LoaderFilesystem file at line 200 and dump all $path.'/'.$shortname_ searched. You should see you JsonLD frame with expanded searched path.

NadaBen commented 8 years ago

in this code ` foreach ($this->paths[$namespace] as $path) { if (is_file($path.'/'.$shortname)) { if (false !== $realpath = realpath($path.'/'.$shortname)) { return $this->cache[$name] = $realpath; }

            return $this->cache[$name] = $path.'/'.$shortname;
        }
    }`

i must do what, i dont understand

conjectwan commented 8 years ago

add var_dump($path.'/'.$shortname); before if (is_file...) to see all searched pathes. You should see your jsonld frame pathes

conjectwan commented 8 years ago

and verify if there are correct

NadaBen commented 8 years ago

i did that ` foreach ($this->paths[$namespace] as $path) { var_dump($path.'/'.$shortname); if (is_file($path.'/'.$shortname)) { if (false !== $realpath = realpath($path.'/'.$shortname)) { return $this->cache[$name] = $realpath; }

            return $this->cache[$name] = $path.'/'.$shortname;
        }
    }`

and i clear cache but still the same error

conjectwan commented 8 years ago

Yes but it should display your entire jsonld file path. Is it displayed and is it correct ?

NadaBen commented 8 years ago

ah it's not displayed

conjectwan commented 8 years ago

Go to Conjecto\Nemrod\Framing\Loader\JsonLdFrameLoader at line 130 in getSource function add a var_dump($name); before return line to see if it enters in function

NadaBen commented 8 years ago

in JsonLdFrameLoader , i dont have getSource , i have it in function getFrame in line 56 as follows:

` /* * Return the decoded frame. / public function getFrame($name, $assoc = true) { $decoded = json_decode($this->getSource($name), $assoc); if ($decoded === null) { throw new \Twig_Error_Loader(sprintf('Unable to decode frame "%s".', $name)); }

    return $decoded;
}`
conjectwan commented 8 years ago

My fault, this function is in FileSystem class. If you do the var_dump at line 56 before the getSource, does it display something during cache:clear ?

NadaBen commented 8 years ago

yes it shows me that: string(42) "@Photos/PhotoResource/PhotoResource.jsonld"

and the same error

conjectwan commented 8 years ago

So it should enter in FileSystem::findTemplate method. Can you display several var_dump to identify when the function is returned

NadaBen commented 8 years ago

when i display var_dump in FileSystem::findTemplate method. it gives me string(42) "@Photos/PhotoResource/PhotoResource.jsonld" too

conjectwan commented 8 years ago

Yes but can you make a var_dump before all returns to see which return is called

NadaBen commented 8 years ago

this one before return $this->cache[$name] = $path.'/'.$shortname; which is returned

conjectwan commented 8 years ago

And what is displayed if you do a var_dump($path.'/'.$shortname) just before this return ?

NadaBen commented 8 years ago

i'm sorry it was a mistake, it is not displayed with any returned in FileSystem::findTemplate method

conjectwan commented 8 years ago

Ok... can you follow the Conjecto\Nemrod\Framing\Loader\JsonLdFrameLoader::getFrame process and with var_dump see where it goes ? I have no other ideas

NadaBen commented 8 years ago

null, when i try to display that too $decoded = json_decode($this->getSource($name), $assoc); it gives me null

NadaBen commented 8 years ago

because getSource gives null , so problem is in findTemplate method

conjectwan commented 8 years ago

in findTemplate methods, where is it return ? Have you register your new bundle in the AppKernel ?

NadaBen commented 8 years ago

yes all bundles are registred
new Conjecto\Nemrod\Bundle\NemrodBundle\NemrodBundle(), new Conjecto\Nemrod\Bundle\ElasticaBundle\ElasticaBundle(), new TestTask\PhotosBundle\TestTaskPhotosBundle(),

it is not displayed with any returned in FileSystem::findTemplate method

NadaBen commented 8 years ago

if i use nemrod witout elastica, can i display, use sparql and create rdf resources and entities, because i want to connect the application with virtuoso ?

conjectwan commented 8 years ago

Try to replace "Photos" in your frame path by "TestTaskPhotos".

Yes you can create, edit and delete RDF resources, especially with forms.

NadaBen commented 8 years ago

when i try it with TestTaskPhotos, it shows me this error [Twig_Error_Loader]
Unable to decode frame "@TestTaskPhotos/PhotoResource/PhotoResource.jsonld"
.

conjectwan commented 8 years ago

Can you go in vendor/twig/twig/CHANGELOG and see which version it is at top of the file please ?

NadaBen commented 8 years ago
conjectwan commented 8 years ago

ok I have the same version.

Can you go on addPath method in filesystem class and add var_dump($path); var_dump($namespace); and see if it display something

NadaBen commented 8 years ago

It gives me string(59) "C:\wamp\www\test\src\TestTask\PhotosBundle/Resources/frames" string(14) "TestTaskPhotos"

and the error [Twig_Error_Loader]
Unable to decode frame "@TestTaskPhotos/PhotoResource/PhotoResource.jsonld"
.

conjectwan commented 8 years ago

Ok so you have to use a @TestTaskPhotos / instead of @ Photos with your frame.

You should have your file at path C:\wamp\www\test\src\TestTask\PhotosBundle\Resources\frames\PhotoResource\PhotoResource.jsonld . Is it the case ? Just to be sure.

NadaBen commented 8 years ago

exactly i must to have this path, i'm using @TestTaskPhotos

conjectwan commented 8 years ago

Can you send me your zipped bundle at my email address please ?

NadaBen commented 8 years ago

Done

conjectwan commented 8 years ago

You have to remove the last coma of your frame after dc:type: {}

conjectwan commented 8 years ago

Does it work ? Your frame was not correct

NadaBen commented 8 years ago

it works now. thank youu a lot