CodeIgniter Forums

Full Version: Doctrine2 custom entity repositories
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ColonelChlorine[/eluser]
Hi all,

I followed Joel's article on how to set up Doctrine2 and managed to get it working with PHPDOC annotations (much better IMO because it doesn't require weird CLI work, and your datamapping happens in your entities so it keeps you from jumping around the place).

After going through the Doctrine documentation article on "Getting Started" they mention what I think is a pretty critical part of any large project: entity repositories (http://www.doctrine-project.org/docs/orm...positories).

Essentially these allow you to write nice "model-like" methods of your entities ... say, "getRecentPosts()" which would return an array of Posts entities fill from the database and ordered by the latest date. This is very important to me, and I'm surprised I couldn't find information on this anywhere on the web.

Does anyone else use entity repositories with CodeIgniter? Where would you store these? Currently my program just flat out fails unless I specifically add a
Code:
require ("/application/models/repositories/postsrepository.php")
statement whenever I try and use a repository in the following fashion
Code:
$this->doctrine->em->getRepository('Posts')->getRecentPosts();

Also how are you namespacing this? I currently have my entities in the "models" folder and they're namespaced as Models. The repositories I namespaced as Repositories.

Heeeelpz!