cycle / docs

Cycle ORM Documentation
https://cycle-orm.dev/docs
110 stars 38 forks source link

Inaccurate install doc🐛 #166

Closed adrienHoareau closed 5 months ago

adrienHoareau commented 7 months ago

No duplicates 🥲.

Database

MySQL

What happened?

Hello

I am interested to use Cycle ORM so I followed the install doc : https://cycle-orm.dev/docs/intro-install/current/en#step-1-install-the-orm but I ran into some issues. At section "Compiling the Schema" the code example shows :

new Annotated\Embeddings($classLocator),        // Recognize embeddable entities
new Annotated\Entities($classLocator),          // Identify attributed entities

the variable $classLocator is set with new \Spiral\Tokenizer\ClassLocator($finder) but Annotated\Embeddings is expected an instance of EmbeddingLocatorInterface and Annotated\Entities is expected an instance of EntityLocatorInterface.

To solve this problem I wrote the following code but I am not sure it is the good solution:

new Annotated\Embeddings(new Annotated\Locator\TokenizerEmbeddingLocator($classLocator)),
new Annotated\Entities(new Annotated\Locator\TokenizerEntityLocator($classLocator)), 

Still in section "Compiling the Schema" there is :

use Doctrine\Common\Annotations\AnnotationRegistry;
// Initialize annotations
AnnotationRegistry::registerLoader('class_exists');

I have a fresh symfony7.0 install without doctrine (because I want to use Cycle) so this namespace doesn't exist. I removed these lines of code and it seems that it is still working good because I was able to persist my entity.

Also the code related to "With the schema compiled, it can be integrated into the ORM:" has a conflict with Cycle\Schema namespace. this solve the conflict :

//I removed  use Cycle\ORM\Schema;
$orm = new ORM\ORM(new ORM\Factory($dbal), new ORM\Schema($schema));

Version

database 2.0
PHP 8.1
roxblnfk commented 7 months ago

@msmakouz we have BC changes in the cycle/annotated package. Looks like we have to update a part of documentation around it