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 6998757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:27:07+00:00 2026-05-27T20:27:07+00:00

As a New Year’s Day hackathon thought I would take Rob Allen’s great zend

  • 0

As a New Year’s Day hackathon thought I would take Rob Allen’s great zend framework 2 beta tutorial and substitute doctrine2 instead of Zend\Db\Table using the ZF2 modules SpiffyDoctrine and SpiffyDoctrineORM.

Everything was going pretty well, got the entity manager going and set up my entity:

<?php

namespace AlbumDoc\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="album")
 */
class Album {

    /**
     * @ORM\Id 
     * @ORM\Column(type="integer");
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    public $id;

    /**
     * @ORM\Column(type="string")
     */
    public $artist;

    /**
     * @ORM\Column(type="string")
     */
    public $title;

    /**
     * global getter
     * 
     * @param type $property
     * @return type 
     */
    public function __get($property) {
        return $this->$property;
    }

    /**
     * Global setter
     * 
     * @param type $property
     * @param type $value 
     */
    public function __set($property, $value) {
        $this->$property = $value;
    }

}

As I’m new to Doctrine and Zend Framework for that mater, I thought I would do a test to see if I could make the Entity Manager save to the database. I setup my code in the indexController as follows:

$em = $this->getLocator()->get('doctrine_em');

$album = new \Application\Entity\Album();
$album->artist = 'Art Ist';
$album->title = 'Cool Title';

$em->persist($album);
$em->flush();

The problem I’m having it that when this code runs I get the following error:

Class Application\Entity\Album is not a valid entity or mapped super class.

From the limited stuff I have found I think the problem has something to do with Doctrine not knowing the entity path or something to do with the AnnotationDriver.

Guessing there is something that needs to be added to the Album module’s config file but can’t find what.

Updated: Since I don’t have enough reputation points to post the answer formally I’ll add the answer here.
Found the solution. There were actually two parts to what was going wrong.

First was a stupid mistake, I forgot to take the .dist off the end of the module.spiffy_doctrine_orm.config.php file that gets dropped into the applications config/autoload directory.

Second part was in this file, I didn’t alter the driver settings of the settings array to point to:

'driver' => array(
    'class'     => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
    'namespace' => 'AlbumDoc\Entity',
    'paths'     => array('module/AlbumDoc/src/AlbumDoc/Entity')
)

This does beg the question of whether it would be possible for each module to hold it’s own entities, if you are setting a global entity path for your application. But that can wait for another day.

  • 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-05-27T20:27:08+00:00Added an answer on May 27, 2026 at 8:27 pm

    (Anwering the second question)

    Yes this is possible and (in my oppinion) the way to go. Your module’s config just has to return a subset of the orm-configuration you want to change/extend.
    Unfortunatelly Doctrine’s drivers don’t seem to support multiple namespaces. Therefore you’ll have to add a new driver for each namespace (not sure about this, correct me if i’m wrong 🙂

    To add a new driver, let you module’s config contain something like:

    return array(
    'di' => array(
        'instance' => array(
            'orm_driver_chain' => array(
                'parameters' => array(
                    'drivers' => array(
                        'mymodule' => array(
                            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                            'namespace' => __NAMESPACE__ . '\Entity',
                            'paths' => array(
                                __DIR__ . '/../src/' . __NAMESPACE__ . '/Entity'
                            )
                        )
                    )
                )
            )
        ),
    ));
    

    This will add a new driver to the configuration without touching any non-module related config-files.

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

Sidebar

Related Questions

I've defined the following route for a simple blog. routes.MapRoute( Blog, blog/{year}/{month}/{day}, new {
Happy new year to you all! I am plotting some graphs and would like
The table: hDate Holiday 17/12/2011 National Day 01/01/2012 New Year .... From the table,
Here's the code: $ical = Date::ICal->new( year => 1964, month => 10, day =>
Good day (and happy New Year), I'm a beginner VB.Net programmer using VS 2008.
I'm coming up with performance goals for the new year, and I thought I'd
Happy New Year SO users! I have an issue that I hope someone can
I have these 2 routes : routes.MapRoute(Agenda, ConfigurationManager.AppSettings[eventsUrl] + /{year}/{month}, MVC.Events.Index(), new { year
function GetDaysInMonth(month, year) { return 32 - new Date(year, month, 32).getDate(); } Ok, I
I'm relatively new to C++ (about one year of experience, on and off). I'm

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.