I am new to Symfony2. Coming from Zend background, I do not see any folder for Models. How do Models and Controllers communicate?
What if I do not want to use Doctrine. Even if I use Doctrine, where will the Models live and how can they communicate with controllers?
Symfony website has some good documentation about symfony2, but it is not on par with the documentation I noticed for symfony1.X .The official documentation does not have what namespaces should be added when using different doctrine methods. Thanks for the community in advance for the tips.
You can create Model manually.
MODELS:
Create MyModel
Set namespace (company\mybundle\models)
CONTROLLERS:
use company\mybundle\models\mymodel;
public function getRecentUserAction ($max = 10) { $user = new MyModel(); $list = $user->getRecentUser($max) // DQL return $this->render('CompanyBundle:controller:index.html.twig',array('list'=>$list)); }
Symfony2 is really about providing the tools for the Controller part, the View part, but not the Model part. It's up to you to create your model by hand or use any other tool, like an ORM.
-- Fabien Potencier (source)
You can choose your way of doing it. You can create your custom Models and use them, or you can use DataMappers or something else. The Symfony2 Standard Edition includes the Doctrine and Propel ORMs. Doctrine is used by default.
Read more about those ORM and how you can use them inside Symfony2 here: doctrine or propel.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With