Bundles Symfony2 is a valuable source of applications based on Symfony2 and third-party packages.
However, you should keep in mind that many of the projects you may discover are outdated, as Sf2 is still unstable and its API changes frequently.
Basically, all you have to do is:
- Ensure that Doctrines packages are included in
ApplicationKernel . Make sure it is configured correctly:
doctrine.dbal: driver: pdo_pgsql host: 127.0.0.1 user: root password: password dbname: my_database charset: utf8 doctrine.orm: mappings: MyApplicationBundle: ~ SomeThirdPartyBundle: ~
Create multiple objects.
- Although you can use the Doctrine2 repositories, I am not a big fan of them. IMO is better off creating their own managers (they can use the original repositories) that will provide a transparent API. You do not need to identify your model layer as an ORM only. You can check out UserBundle by FriendsOfSymfony , as their approach is pretty good.
End use:
$posts = $this->get('myapp.post_manager')->findRecentlyUsed(new \DateTime('-1 week')); return $this->render('MyApp:Post:list.html.twig', array( 'posts' => $posts ));
source share