FabienPennequin / FPNTagBundle

This bundle allows to tag your Doctrine entities easily
http://knpbundles.com/FabienPennequin/FPNTagBundle
76 stars 50 forks source link

Unable to set up as documented #21

Closed succinct closed 9 years ago

succinct commented 11 years ago

I followed the instructions in readme.md (using the Annotation version), and when I try to call $tagManager->loadOrCreateTag('reptile') I receive the following errors:

[2/2] QueryException: [Semantical Error] line 0, col 50 near 'name IN('rep': Error: Class Vox\CoreBundle\Entity\Tag has no field or association named name   
[1/2] QueryException: SELECT t FROM Vox\CoreBundle\Entity\Tag t WHERE t.name IN('reptile')

I couldn't get the XML version to worth either - it throws this error:

Class "Vox\CoreBundle\Entity\Tag" sub class of "FPN\TagBundle\Entity\Tag" is not a valid entity or mapped super class.

Additonally, I'm unable to call php app/console doctrine:generate:schema due to the following error:

  [Doctrine\DBAL\Schema\SchemaException]
  There is no column with name 'resource_type' on table 'Tagging'.
yanickj commented 11 years ago

I encountered this issue as well, but it was due to extending the wrong Tagging class (namespace error). Be sure to use the proper namespace...

<?php
   use FPN\TagBundle\Entity\Tagging as BaseTagging 
succinct commented 11 years ago

@yanickj thanks for the reply; I did notice that the namespace was erroneous, and I still get the same errors after fixing it.

yanickj commented 11 years ago

@succinct did you run a doctrine migration after you updated the BaseTagging class? I forgot to mention that in my previous comment.

succinct commented 11 years ago

@yanickj we're not using the doctrine migrations bundle, is it required for this?

yanickj commented 11 years ago

I meant to say that I had to update the schema after putting the correct namespace for the parent class.

yanickj commented 11 years ago

Forgive me if you have already tried this, but I had to run the following after I resolved the namespace error:

app/console doctrine:migrations:diff; 
app/console doctrine:migrations:migrate; 

The migrate command will alter your schema so all cautions apply.

rvanlaak commented 10 years ago

I'm using Symfony 2.4.3 and am also unable to generate the correct database scheme. It seems like my Tag and Tagging entity do not inherit the fields of the parent BaseTag and BaseTagging when using Annotations.

[Doctrine\DBAL\Schema\SchemaException]
There is no column with name 'resource_type' on table 'Tagging'.

Fixing the namespace does not solve the problem for me. It looks like using annotations can not be combined with the Tag.orm.xml file

rvanlaak commented 10 years ago

I was able to fix this by defining all fields, and adding the ORM annotations. The slug automatically is updated via Sluggable

https://gist.github.com/Rvanlaak/9409592