Doctrine annotation auto-load

79 views
Skip to first unread message

sighin

unread,
Jun 12, 2015, 11:46:06 AM6/12/15
to symfony-...@googlegroups.com
Hi
 
I got the error, of which phrase msg I put into google as following:
 
"[Semantical Error] The annotation "@Doctrine\ODM\PHPCR\Mapping\Annotations\NodeName" in property does not exist, or could not be auto-loaded."
 
for which 2nd result (for me) directed me at this PDF, page 55:
 
 
Yes, this fix worked after modifying app/autoload.php. I wonder why this happens that Annotations aren't auto-loaded?
 
Thx, cheers

David Buchmann

unread,
Jun 13, 2015, 6:15:20 AM6/13/15
to symfony-...@googlegroups.com
hi sighin,

glad you managed to find the solution.

this is documented in the setup instructions of phpcr-odm and if you
start with the symfony-cmf/standard-edition or sandbox, it will already
be present.

did you follow some tutorial that forgets to mention this step? if so
please point us to it so we can fix it.

i think there is no easy solution to better report what is going wrong -
its the annotation system which knows nothing about phpcr-odm specifically.

cheers,david

On 12.06.2015 17:46, sighin wrote:
> Hi
>
> I got the error, of which phrase msg I put into google as following:
>
> "[Semantical Error] The annotation
> "@Doctrine\ODM\PHPCR\Mapping\Annotations\NodeName <mailto:"[Semantical
> Error] The annotation
> "@Doctrine\ODM\PHPCR\Mapping\Annotations\NodeName>" in property does not
> exist, or could not be auto-loaded."
>
> for which 2nd result (for me) directed me at this PDF, page 55:
>
> http://pl.scribd.com/doc/166033629/Symfony-Cmf-Master#scribd
>
> Yes, this fix worked after modifying app/autoload.php. I wonder why this
> happens that Annotations aren't auto-loaded?
>
> Thx, cheers
>
> --
> You received this message because you are subscribed to the Google
> Groups "symfony-cmf-devs" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to symfony-cmf-de...@googlegroups.com
> <mailto:symfony-cmf-de...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

--
Liip AG // Agile Web Development // T +41 43 500 39 80
CH-8005 Zurich // PGP 0xA581808B // www.liip.ch

sighin

unread,
Jun 13, 2015, 9:13:23 AM6/13/15
to symfony-...@googlegroups.com
Hi David,
 
Thx for reply!
 
This is kind of surprising that phpcr-odm needs this extra setting. What's more surprising, it's only my linux server which requires such a setting; on my dev environment (which is on Windows) this all stuff works very well. Actually, it's for the first time for me as far as I remember that sth having to do with PHP works on Windows but not Linux out of the box.
 
I saw no other SF bundles or components requiring a need for editing app/autoload.php, but from what you're saying it seems to be ok with this setting always. I also checked on my Windows dev env this setting - it seems to not harm (but not change as well) anything - or am I incorrect here?
 
For the last part of documentation, well... I'm using SF-CMF stuff for quite a long time, particularly for this app. I followed many tutorials, from the SF website included. But I think it wasn't mentioned on the SF website to edit this file.
 
cheers

Daniel Leech

unread,
Jun 13, 2015, 11:21:40 AM6/13/15
to symfony-...@googlegroups.com
On Sat, Jun 13, 2015 at 12:14:54PM +0200, David Buchmann wrote:
> hi sighin,
>
> glad you managed to find the solution.
>
> this is documented in the setup instructions of phpcr-odm and if you
> start with the symfony-cmf/standard-edition or sandbox, it will already
> be present.
>
> did you follow some tutorial that forgets to mention this step? if so
> please point us to it so we can fix it.
>
> i think there is no easy solution to better report what is going wrong -
> its the annotation system which knows nothing about phpcr-odm specifically.

Assuming we are talking about the PHPCR-ODM specific registration with
the AnnotationRegistry. Do we actually really need it?

https://github.com/symfony-cmf/symfony-cmf-standard/blob/master/app/autoload.php#L22

The Routing Auto tutorial ommits it completely and always has. I think
it is a legacy thing, perhaps from when the AnnotationLoader did not use
the autoloader.

Cheers

Dan

p.s. I just removed the line from my website and that is working fine.

David Buchmann

unread,
Jun 19, 2015, 2:15:29 PM6/19/15
to symfony-...@googlegroups.com
afaik you need things when using annotations. though maybe when they are
place in the right path for namespace it just happens to work with a new
enough autoloader.

symfony-standard (not the cmf one) still carries the line
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
https://github.com/symfony/symfony-standard/blob/2.8/app/autoload.php
so i assume doctrine orm still needs that?

indeed i don't find any reference to do more than that in our
documentation, which indicates there is at least some omission.
the phpcr-odm documentation however mentions the need for registering:
http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/installation-configuration.html#annotation-mapping-driver

phpcr-odm tests do the autoloading:
https://github.com/doctrine/phpcr-odm/blob/master/tests/bootstrap.php

as does the testing component we use for DoctrinePHPCRBundle:
https://github.com/symfony-cmf/Testing/blob/master/bootstrap/bootstrap.php#L30

we should try to find out which parts of this are needed for annotation
mapping and which are legacy. and then document the parts that are required.

sighin, if you want to help us with this, can you try a pull request on
phpcr-odm to remove things from the autoloading that seem unneeded? then
we can see if tests still succeed or not.

cheers,david
Reply all
Reply to author
Forward
0 new messages