Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:17:02+00:00 2026-06-05T14:17:02+00:00

I am trying to use Doctrine Common to create my own annotation. http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html does

  • 0

I am trying to use Doctrine Common to create my own annotation. http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html does not match https://github.com/doctrine/common because Call to undefined method Doctrine\\Common\\Annotations\\AnnotationReader::setDefaultAnnotationNamespace and PHP Fatal error: Call to undefined method Doctrine\\Common\\Annotations\\AnnotationRegistry::registerAnnotationNamespace. I checked the source, they are not there. According to git log they were removed a year ago.

I have a PSR-0 autoloader going (from Symfony). So I have a file where the PSR-0 loader expects:

namespace My\Test;

/**
 * @Annotation
 */
class Foo {

}

Another class

namespace My\Annotated

/**
 * @My\Test\Foo
 */
class Test {
}

Reader:

namespace My\Reader

use ReflectionClass;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use My\Test\Foo;

$reader = new AnnotationReader();
$reflectionClass = new ReflectionClass('My\\Annotated\\Test');
$classAnnotations = $reader->getClassAnnotations($reflectionClass);
var_dump($classAnnotations);

Gets: "[Semantical Error] The annotation "@My\\Test\\Foo" in class My\\Annotated\\test was never imported. Did you maybe forget to add a "use" statement for this annotation?" I ilikely did but for my life I can’t figure out where to add it. And I really would like to just use @Foo if possible.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:17:05+00:00Added an answer on June 5, 2026 at 2:17 pm

    Autoloading is apparently handled by AnnotationRegistry::registerAutoloadNamespace which is a PSR-0 autoloader. Documentation/source.

    I found that you can do a use My\Test\Foo in the annotated file to use @Foo as an annotation. And the reason for that is possible is because Doctrine re-parses the file solely for use statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I'm trying to use Doctrine to retrieve some data. I have some basic
I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I am trying to use do the most simple update query but Doctrine issues
I'm trying to create a custom DQL function to allow me to use the
when i trying to create a module using the command php symfony doctrine:generate-module --with-show
im trying to use the doctrine pager but its errored: Fatal error: Class 'Doctrine_Pager'
I am trying to use a pear installation of Doctrine, it seems like all
I am trying to use custom sorting in Doctrine 2 (using MySQL). Code looks
Im trying use a Java annotation in a Groovy class but have trouble to
I'm trying to use regular expressions to query Mongodb using Doctrine's Mongodb ODM on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.