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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:14:02+00:00 2026-05-27T14:14:02+00:00

I started a new project and wanted to use Doctrine 2 within the Zend

  • 0

I started a new project and wanted to use Doctrine 2 within the Zend Framework (1.11).

I configured everything within the Bootstrap & Config, which seemed to be fine.

Here is my first model that I created for use:

<?php
namespace Entities;
/**
 * @Entity
 * @Table(name="posts")
 */
class Post
{

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

    /** @Column(length=100,nullable=true) */
    public $title;

    /** @Column(length=2000) */
    public $message;

    /** @Column(type="integer") */
    public $userId;

    /** @Column(type="timestamp") */
    public $dateAdded;

}

And here is the controller:

<?php

class CityController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
        $em = Zend_Registry::get('em');

        $group = $em->find('Entities\Post', 1);
    }


}

When I try accessing the Entities\Post model, it just errors out saying that it doesn’t exist. I’m sure it’s a Zend naming convention problem, but I tried a few different things, and nothing seemed to work.

Any ideas? And I did look through all the Doctrine 2/Zend tutorials I could find and none of them helped much.

* UPDATE *

Here is my Doctrine init in the bootstrap:

public function _initDoctrine() {
    // include and register Doctrine's class loader
    require_once('Doctrine/Common/ClassLoader.php');
    $classLoader = new \Doctrine\Common\ClassLoader(
        'Doctrine',
        APPLICATION_PATH . '/../library/'
    );
    $classLoader->register();

    // create the Doctrine configuration
    $config = new \Doctrine\ORM\Configuration();

    // setting the cache ( to ArrayCache. Take a look at
    // the Doctrine manual for different options ! )
    $cache = new \Doctrine\Common\Cache\ArrayCache;
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);

    // choosing the driver for our database schema
    // we'll use annotations
    $driver = $config->newDefaultAnnotationDriver(
        APPLICATION_PATH . '/models'
    );
    $config->setMetadataDriverImpl($driver);

    // set the proxy dir and set some options
    $config->setProxyDir(APPLICATION_PATH . '/models/Proxies');
    $config->setAutoGenerateProxyClasses(true);
    $config->setProxyNamespace('App\Proxies');

    // now create the entity manager and use the connection
    // settings we defined in our application.ini
    $connectionSettings = $this->getOption('doctrine');
    $conn = array(
        'driver'    => $connectionSettings['conn']['driv'],
        'user'      => $connectionSettings['conn']['user'],
        'password'  => $connectionSettings['conn']['pass'],
        'dbname'    => $connectionSettings['conn']['dbname'],
        'host'      => $connectionSettings['conn']['host']
    );
    $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);

    // push the entity manager into our registry for later use
    $registry = Zend_Registry::getInstance();
    $registry->em = $entityManager;

    return $entityManager;
}

And here is the config for doctrine (in application.ini):

doctrine.conn.host = 'localhost'
doctrine.conn.user = '****'
doctrine.conn.pass = '****'
doctrine.conn.driv = 'pdo_mysql'
doctrine.conn.dbname = '****'
doctrine.path.models = APPLICATION_PATH "/models"

As you can see, it’s looking for the models in the APPLICATION_PATH "/models"

  • 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-27T14:14:03+00:00Added an answer on May 27, 2026 at 2:14 pm

    Assuming your doctrine setup is correct and Zend_Registry::get('em'); returns entitymanager then here is the correct syntax for Zend Framework integrated doctrine ORM:

    $group=$em->getRepository ( 'Entities\Post' )->find (1));
    

    or

    $group=$em->getRepository ( 'Entities\Post' )->findOneByUserid (1));
    

    If you are looking for a valuable book for doctrine and ZF,then “Easy PHP Websites with the Zend Framework” is a good place to start.

    If problem persists, then try changing

    /** @Id @Column(type="integer") @GeneratedValue */
    

    to

    /**
     * @Id @Column(type="integer")
     * @GeneratedValue(strategy="AUTO")
     */
    

    check here for annotation documentation.
    PS:If you have issues regarding ZF and Doctrine, please input which ZF-Doctrine integration method you are using since then.

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

Sidebar

Related Questions

I recently started a small project in which I wanted to use zxing. I
I just started a new project and wanted to use HaskellDB in the beginning.
I have started a new mvc project and clicked on project\properties\web - use local
I recently started a new personal project to learn Entity Framework. My end goal
I've recently started my new private project. The main goal which I want to
I've recently started a new web development project for an embedded device and wanted
I just started a new Haskell project and wanted to set up a good
I wanted to get some advice, I have started on a new project to
I have a major problem with project configurations. Everything started when I wanted to
I've started work on a simple newtworking project which creates a new thread for

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.