开发者

How do I use Symfony's Doctrine model classes outside of Symfony?

开发者 https://www.devze.com 2023-02-14 06:42 出处:网络
Is there a way to use Doctrine using the model classes I\'ve already setup for my Symfony applications without having to call Symfony with all that overhead?

Is there a way to use Doctrine using the model classes I've already setup for my Symfony applications without having to call Symfony with all that overhead?

This is more to satisfy a curiosity than anything else. For all the scripts I've used, I've just been able to instantiate Symfony (which typically turns out nice since I have all of the features that I'm used to working with on this particular project. But there has to be a way to load Doct开发者_Go百科rine and use the Symfony model classes without Symfony... Right?


Doctrine isn't dependet on symfony. Doctrine is a "framework" on its own. It has it's own autoloading and can therefore work with it's classes like a regular PHP app. You can integrate Doctrine with other frameworks if you want (like CodeIgniter or Zend). So you have every freedom you need without the need to do some tedious migration of your models/data/... from one system to another.


I've come to the conclusion there really isn't a way to use the model classes from Symfony elsewhere. With a little work, you can port over the classes to a new Doctrine model (even if you use the generator, since the main model class just extends the base which extends sfDoctrineRecord (from the API docs, you can see which functions will need to be removed).

Otherwise, there isn't a practical way of doing that.

Anytime I need to access the Symfony model, I'm making a task or plugin since I do typically need part of Symfony's functionality.

As far as Symfony2 goes, just looking at the documentation makes me want to run screaming. It's not mature in any form or fashion (but, then again, neither is Symfony "legacy"). So, I'm not sure if the process would be any easier there.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号