Open mikebell opened 9 years ago
Does this help at all? It seems like it would not matter if things are working for the schema part but maybe it loads up slightly differently?
@simensen was also my first thought ;-), Cause everything else seems to be ok
Thanks for the quick support, I've tried adding the AnnotationRegistry to both my console.php and index.php (where orm.em.options is) and still no luck.
@mikebell Where is the orm:validate-schema command coming from? And which command are you running to try and create your schema? Maybe posting your console.php to a gist/pastebin would be useful?
Here is my console.php - https://gist.github.com/mikebell/b7f7e94887cd00723830
It resides inside src/
@mikebell Nothing is jumping out at me as being wrong. :-/ I haven't used those commands like that in awhile so I'm not sure what they are looking for or are expecting. You can look at the command that works (ValidateSchemaCommand
) and see how it differs from the one that does not (CreateCommand
). It is possible the commands in the SchemaTool
namespace have different dependencies than the ValidateSchemaCommand
. I'd look to see how each is using the HelperSet
and see if there is something else you need to be adding to it in order for the CreateCommand
to work.
If you end up finding a solution here it would be great if you could report that here so we can track this down in the future or look to adding it into some documentation somewhere.
@mikebell it seems you register the Annotation Registry after calling the entity manager Call it at first after the use statments.
@dominikzogg d'oh. i was looking at how far down the annotation registry was being added but i decided in the end that i wouldn't mention it. i usually do that right after the class loader is created so i've never run into anything like this.
@mikebell my guess is that @dominikzogg is right on this. try moving the annotation registry call before you get $em from the container.
thank you so much, @dominikzogg!
@simensen i hope it's the solution and you know i try to support this provider as it would be mine ;-)
Seem to be getting somewhere now. I've updated my console.php to - https://gist.github.com/mikebell/b7f7e94887cd00723830
I know get:
PHP Fatal error: Uncaught exception 'InvalidArgumentException' with message 'A callable is expected in AnnotationRegistry::registerLoader().' in /var/www/kardio.dev/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:111
Stack trace:
#0 /var/www/kardio.dev/src/console.php(14): Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(Array)
#1 /var/www/kardio.dev/src/console(3): require('/var/www/kardio...')
#2 {main}
thrown in /var/www/kardio.dev/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 111
@mikebell change 10/11 with 13/14
I think this is because of how require_once
works. I believe you are probably doing require_once
in web/index.php
already. So when you require_once
again, it doesn't actually return the $loader
since it was already required in web/index.php
. I'd suggest putting these lines just before you include web/index.php
.
$loader = require_once __DIR__.'/../vendor/autoload.php';
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
All of which is a longer form (with explanation) of what @dominikzogg just said while I was writing this. :)
Back to the "No Metadata Classes to process." error again. I'm going to park this for now, thanks for both your help, didn't expect to get this much help!
@mikebell your welcome
Try and change:
"path" => __DIR__."/../src/Example/Api/Entities",
with:
"path" => __DIR__."/../src",
That should work.
My problem with the "No Metadata Classes to process." error was that my generated entities were missing a namespace. Looks like it needs to be the same as the provider's "namespace" config value.
@mikebell Maybe to give you some more ways to use this provider. I used it in my silex skeleton which by default has example entities setup. It lacks proper documentation so if you need help setting it up then gimme a shout. Skeleton can be found at:
exact same problem here with no success!
Hello. You need to set alias to 'core' and disable use_simple_annotation_reader.
['mappings' => [
[
'alias' => 'core',
'type' => 'annotation',
'namespace' => 'TestApp\Entity',
'path' => __DIR__ . '/TestApp/Entity',
'use_simple_annotation_reader' => false,
],
]]
It's an old post but if someone have the same problem, I suggest adding "use_simple_annotation_reader" => false,
it worked for me.
"orm.em.options" => array(
"mappings" => array(
// Using actual filesystem paths
array(
"type" => "annotation",
"namespace" => "Example\Api\Entities",
"path" => __DIR__."/../src/Example/Api/Entities",
"use_simple_annotation_reader" => false,
),
),
),
Hope it will helps someone
I'm trying to get this working in Silex but struggling when setting it up.
I get "No Metadata Classes to process." when trying to create the schema through my console app.
The schema validates fine if I run orm:validate-schema
Below is my config. Example\Api\Entities is mapped to "src/Example/Api/Entities" in my composer.json file (similar namespaces are working)
Changing the path to a none existant path breaks validate-schema as expected.
This is my entity file
I'm not really sure how to fix this. Any help would be greatly appreciated.