Skip to content
This repository has been archived by the owner on Feb 5, 2024. It is now read-only.

Uncaught exception 'Doctrine\ODM\CouchDB\Mapping\MappingException' with message is not a valid document or mapped super class. #148

Open
garavito16 opened this issue May 2, 2018 · 0 comments

Comments

@garavito16
Copy link

garavito16 commented May 2, 2018

Very good with everyone, please could you help me with this error that appears to me, already tried of everything but I do not get to solve.

Fatal error: Uncaught exception 'Doctrine\ODM\CouchDB\Mapping\MappingException' with message 'Class Documents\Article is not a valid document or mapped super class.' in C:\xampp\htdocs\CouchDoctrineODM\lib\Doctrine\ODM\CouchDB\Mapping\MappingException.php:23
Stack trace:
#0 C:\xampp\htdocs\CouchDoctrineODM\lib\Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver.php(62): Doctrine\ODM\CouchDB\Mapping\MappingException::classIsNotAValidDocument('Documents\Artic...')
#1 C:\xampp\htdocs\CouchDoctrineODM\lib\Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory.php(71): Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver->loadMetadataForClass('Documents\Artic...', Object(Doctrine\ODM\CouchDB\Mapping\ClassMetadata))
#2 C:\xampp\htdocs\CouchDoctrineODM\lib\vendor\doctrine-common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(302): Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory->doLoadMetadata(Object(Doctrine\ODM\CouchDB\Mapping\ClassMetadata), NULL, false, Array)
#3 C:\xampp\htdocs\CouchDoctrineODM\lib in C:\xampp\htdocs\CouchDoctrineODM\lib\Doctrine\ODM\CouchDB\Mapping\MappingException.php on line 23

This is my file Documents\Article.php

created = new \DateTime("now"); } public function getId() { return $this->id; } public function getTitle() { return $this->title; } public function setTitle($title) { $this->title = $title; } public function getBody() { return $this->body; } public function setBody($body) { $this->body = $body; } public function getCreated() { return $this->created; } } And this is my file boostrap.php. register(); $loader = new \Doctrine\Common\ClassLoader("Doctrine", __DIR__ . "/lib"); $loader->register(); $loader = new \Doctrine\Common\ClassLoader("Symfony", __DIR__ . "/lib/vendor"); $loader->register(); $loader = new \Doctrine\Common\ClassLoader("Documents", __DIR__); $loader->register(); $database = "doctrine_sandbox"; $httpClient = new \Doctrine\CouchDB\HTTP\SocketClient(); // create database if not existing $resp = $httpClient->request('PUT', '/' . $database); $reader = new \Doctrine\Common\Annotations\AnnotationReader(); $paths = __DIR__ . "/Documents"; $metaDriver = new \Doctrine\ODM\CouchDB\Mapping\Driver\AnnotationDriver($reader, $paths); $config = new \Doctrine\ODM\CouchDB\Configuration(); $config->setProxyDir(\sys_get_temp_dir()); $config->setMetadataDriverImpl($metaDriver); $config->newDefaultAnnotationDriver(array("/Documents")); $config->setLuceneHandlerName('_fti'); $couchClient = new \Doctrine\CouchDB\CouchDBClient($httpClient, $database); $dm = \Doctrine\ODM\CouchDB\DocumentManager::create($couchClient, $config); $article1 = new \Documents\Article(); $article1->setTitle("Who is John Galt?"); $article1->setBody("Find out!"); $dm->persist($article1); $dm->flush(); ********************************************************************************************** If you get to create the database, the error is in the mapping.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant