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

  • Home
  • SEARCH
  • 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 8847813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:16:50+00:00 2026-06-14T12:16:50+00:00

I started to develop new application, it’s my first application written in ZF2. I

  • 0

I started to develop new application, it’s my first application written in ZF2. I have some experience about making application with ZF1 with Doctrine1, but now I would like to do application with using ZF2 and Doctrine2.
Default entities folder is in the module directory. I would like to have one models folder, which is shared in whole application. So I’ve prepared application structure like this:

config
models
 generated
module
 Administration
 Application
public
vendor

I have designed database (MySQL) and imported it to XML form, using Doctrine CLI. I’ve generated also models. But now I have problem – how to use it in my modules? I’ve prepared some code:

protected $em;

public function setEntityManager(EntityManager $em)
{
    $this->em = $em;
}

public function getEntityManager()
{
    if (null === $this->em) {
        $this->em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
    }
    return $this->em;
}

public function indexAction()
{
    return new ViewModel(array(
        'carriers' => $this->getEntityManager()->getRepository('Carrier')->findAll()
    ));
}

And I’ve got an error ‘Class Carrier not found’. It is a problem with paths, but I’m totally newbie in ZF2 and I’ve no idea how to configure it…

  • 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-14T12:16:51+00:00Added an answer on June 14, 2026 at 12:16 pm

    You define the path to Doctrine 2’s entities within configuration. Now i assume you have a configuration somewhere similar to this:

    'doctrine' => array(
        'driver' => array(
            __NAMESPACE__ . '_driver' => array(
                'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
                'cache' => 'array',
                'paths' => array(__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity')
            ),
            'orm_default' => array(
                'drivers' => array(
                    __NAMESPACE__ . '\Entity' => __NAMESPACE__ . '_driver'
                )
            )
        )
    )
    

    Basically what you have to do is to Map the paths correctly. Within the orm_defaults you can define the driver for each module separately, or just use a global driver.

    Within __NAMESPACE__ . '_driver' you define a driver with the given name and also define where exactly the entities get stored. In your case this would probably be something like

    'paths' => array(__DIR__ . '/../src/Administration/Entity')
    

    Or whatever your Module is named where your entities are stored. In this case Administration

    Additionally, always assign the fully qualified repository name like this:

    ->getRepository('NAMESPACE\Entity\Carrier')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started to develop a brand new application and I have two
I started using emacs and slime to develop some little service. I have found
I started develop a distributed application and we have a big dilemma! We need
As I'm just starting to develop an iPad application & have started getting used
We started to develop a new application using .NET 4.0 Beta 2. Should we
I just started to develop with Google AppEngine and now I have my first
I have started to develop E-Learning application and want to know Are There any
At a new job I started, we have both a Java application that handles
New to ios development, looking for some guides, Can I develop ios application on
I'm new to Android Development and am currently trying to develop my first application

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.