doctrine / couchdb-odm

A Document Mapper based on CouchDB
http://www.doctrine-project.org
MIT License
150 stars 53 forks source link

Fatal error: Uncaught Error: Class 'Doctrine\Instantiator\Instantiator' not found #146

Open Th3Ov3r opened 6 years ago

Th3Ov3r commented 6 years ago

please help me, it may be happening. This is the error Fatal error: Uncaught Error: Class 'Doctrine\Instantiator\Instantiator' not found in C:\xampp\htdocs\couchdb-odm\lib\Doctrine\ODM\CouchDB\Mapping\ClassMetadata.php:219 Stack trace: #0 C:\xampp\htdocs\couchdb-odm\lib\Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory.php(191): Doctrine\ODM\CouchDB\Mapping\ClassMetadata->__construct('MyApp\Document\...') #1 C:\xampp\htdocs\couchdb-odm\lib\vendor\doctrine-common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(299): Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory->newClassMetadataInstance('MyApp\Document\...') #2 C:\xampp\htdocs\couchdb-odm\lib\Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory.php(178): Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->loadMetadata('MyApp\Document\...') #3 C:\xampp\htdocs\couchdb-odm\lib\vendor\doctrine-common\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(212): Doctrine\ODM\CouchDB\Mapping\ClassMetadataFactory->loadMetadata('MyApp\Document\...') #4 C:\xampp\htdocs\co in C:\xampp\htdocs\couchdb-odm\lib\Doctrine\ODM\CouchDB\Mapping\ClassMetadata.php on line 219

here my file boostrap.php.

`<?php $couchPath = "lib"; require_once $couchPath . "/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php";

$loader = new \Doctrine\Common\ClassLoader("Doctrine\Common", $couchPath . "/vendor/doctrine-common/lib"); $loader->register();

$loader = new \Doctrine\Common\ClassLoader("Doctrine\ODM\CouchDB", $couchPath); $loader->register();

$loader = new \Doctrine\Common\ClassLoader("Doctrine\CouchDB", $couchPath); $loader->register();

$loader = new \Doctrine\Common\ClassLoader("Symfony", $couchPath . "/vendor"); $loader->register();

$annotationNs = 'Doctrine\ODM\CouchDB\Mapping\Annotations'; Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($annotationNs, $couchPath);

$databaseName = "couchdb_odm"; $documentPaths = array("MyApp\Documents"); $httpClient = new \Doctrine\CouchDB\HTTP\SocketClient(); $dbClient = new Doctrine\CouchDB\CouchDBClient($httpClient, $databaseName);

$config = new \Doctrine\ODM\CouchDB\Configuration(); $metadataDriver = $config->newDefaultAnnotationDriver($documentPaths);

$config->setProxyDir(DIR . "/proxies"); $config->setMetadataDriverImpl($metadataDriver); $config->setLuceneHandlerName('_fti');

$dm = new \Doctrine\ODM\CouchDB\DocumentManager($dbClient, $config);

use MyApp\Document\BlogPost;

require_once 'MyApp/Documents/BlogPost.php';

$blogPost = new BlogPost(); $blogPost->setHeadline("Hello World!"); $blogPost->setText("This is a blog post going to be saved into CouchDB");

$dm->persist($blogPost); $dm->flush();`

Th3Ov3r commented 6 years ago

Here my file BlogPost.php `<?php namespace MyApp\Document;

/ @Document */ class BlogPost { /* @Id / private $id; / @Field(type="string") */ private $headline; /* @Field(type="string") / private $text;

public function setHeadline($headline)
{
    $this->headline = $headline;
}

public function getHeadline()
{
    return $this->headline;
}

public function setText($text)
{
    $this->text = $text;
}

public function getText()
{
    return $this->text;
}

}`

Ocramius commented 6 years ago

The doctrine class loader should no longer be used, as composer completely replaces it: are your examples coming from the docs? If so, then we'll likely need to upgrade or deprecate that section.

Th3Ov3r commented 6 years ago

Yes, the examples take them from doctrine couchdb documentation. What is the correct way to download and load the libs, help me please.

mikeSimonson commented 6 years ago

On the command line you can composer require doctrine/couchdb-odm and then you just need to require_once the vendor/autoload.php file.

Can you point us where you found the outdated documentation that show the use of the doctrine classLoader ?

Th3Ov3r commented 6 years ago

Here docs http://docs.doctrine-project.org/projects/doctrine-couchdb/reference/configuration.html#class-loading

Now, I'm having this problem C:\xampp\htdocs\couchdb-odm-master>composer require "doctrine/couchdb-odm" [InvalidArgumentException] Could not find package doctrine/couchdb-odm.

Did you mean one of these? doctrine/couchdb-odm doctrine/couchdb-odm-bundle

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] []...

mikeSimonson commented 6 years ago

Thanks for the docs link.

The error that you are seeing from composer is weird. It looks like there is an invisible character because the error mention the right package. Also you shouldn't require doctrine/couchdb-odm in what looks like a git clone from doctrine/couchdb-odm but in your project where you want to use it.

Th3Ov3r commented 6 years ago

Yes, very strange. Try other libs, such as, for example,

composer require "doctrine/mongodb-odm"

If it worked well.

Th3Ov3r commented 6 years ago

try another pc. I keep throwing error. But this time the exception is different. What could be happening? I think he asks me to specify the version, what version should I specify?

C:\xampp\htdocs\couchdb>composer require doctrine/couchdb-odm

[InvalidArgumentException] Could not find a version of package doctrine/couchdb-odm matching your mini mum-stability (stable). Require it with an explicit version constraint allo wing its desired stability.

require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [-- update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--pref er-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authorita tive] [--apcu-autoloader] [--] []...

mikeSimonson commented 6 years ago

Sorry but I have no idea what's going on, but it's not a couchdb-odm bug.