Use Active Record Gii Component for de-coupled usage like with symfony components

Hi,

is there any non time intensive way to use the active record component from Yii2 “standalone”? I would need only the active record component along with Gii in a project. The symfony framework allows to use it’s components de-coupled. Is Yii2 able for this, too?

Thanks!

I believe that you can do that:

http://www.yiiframework.com/doc-2.0/guide-tutorial-yii-integration.html#using-yii-in-others

Haven’t tried it myself, though.

Thanks for the answer. The article advices to boot the entire framework. That "can" be a way. Hopefully at least bower etc. can be de-coupled if no frontend is needed. Does anybody know how to boot only the component?

It does not advice us to boot the framework, actually. (By not calling the ‘run’ method)

Only construct it and configure whatever component that we want.

In your case, the db component.

<br /><br /><br />

Hi, The answer is no, as long as you couldnt use it’s components without using Yii::$app (or Yii::app() for Yii1.1) Yii is tightly coupled even it’s Dependency injection container is coupled to the Yii class Yii::$container

However, the entire framework is relatively small - especially if you only load up one component.

I don’t think it’s so small. It has about 20 MB of size.

20MB is not much.

I have installed a small selection of Kartik’s extensions - and it weighs in at a bit over 10MB.

And I am using Gulp for my build chain - the node_modules folder is over 100MB already…

Each to his own, I think.

20 MB are 262144 lines of code in 80 characters per line. Way too much code to solve a specific use case without doing it with Yii on it’s own.

That’s pitty. Because the Active Record component is much more powerful than Doctrine, which can be used de-coupled. But Doctrine does not have eager and lazy loading along with translated joins into more performant select queries.

Yii2 active record is realy powerful but is just a tool, Doctrine implements Data Mapper patern, so choosing Doctrine or Active Record depends on your Application design more then tools features, you should digg deeper in Doctrine to find how it can perfom eager loading if you realy need decoupled Active Record implementation without the whole framework you may look at Propel or similar implementation