I have been very puzzled about the concept of model (entity) persistence in Symfony2. AFAIK, there is nothing like model_instance->save() in Symfony2. Instead, it must be invoked in a controller by retrieving the doctrine entity manager, and then persist the model_instance and flush the model_instance.
In fact, if I want to write a script that is invoked periodically to persist models, it seems impossible, because it must invoke the controller, and yet I don't see why a script requires a web server to be present, but not just work on the object model without touching the web server.
I really appreciate how to resolve the problems above. Thank you!
You're right, Doctrine2 is an implementation of the DataMapper pattern. So the concepts are different from the ActiveRecord that is implemented by some other ORMs like Doctrine1 and Propel.
By default, when you create an entity with some relations, you have to persist your main entities and its relations manually. But you can change this behavior activating the persistence cascade:
In your comments you mentioned testing. There is a cookbook library about testing doctrine right here: http://symfony.com/doc/current/cookbook/testing/doctrine.html
Symfony2 is actually a decoupled bundle of libraries. while the default way to use doctrine is through the controller, you can load the doctrine libraries directly. I'm not sure how you access the doctrine bundle on its own, but I'm sure the examples in the article above will help with that.
Also, Fabien Potencier (the lead developer of symfony) gave a talk recently about Symfony being a bunch of bundles which can be used independently. He covered the basics of how to use a large portion of the bundles. You can view that here: http://symfony.com/video/Paris2011/583