<p><a href="https://www.yiiframework.com/doc/guide/2.0/en/structure-models" rel="noreferrer">Models</a>  are classes that contains abstractions of the reality, for example you could have the model car that contains the technical information about it, how many wheels it has and it's brand. Models are usually not supposed to contain any logic. So it's just a "container" with information </p>

<p><a href="https://www.yiiframework.com/doc/guide/2.0/en/concept-components" rel="noreferrer">Components</a> are more like services that contains business logic to work with your models, for example the service car would handle the logic to let your car model drive and move and such. Components in Yii2 are mostly (not always) treated as singletons while you want to have many different instances of your models </p>

CC BY-SA 4.0
2018-08-28T19:51:42.830Z
Thanks for the clarification! I just realized Services in Craft were actually extending Components in Yii. A bit confusing in terminology, but I'm starting to wrap my head around it!
Lazlo
CC BY-SA 4.0
2018-08-29T06:06:58.697Z
A minor caveat, and a caution.

First the caveat: there is a strong argument that [anemic models are an anti-pattern](https://www.martinfowler.com/bliki/AnemicDomainModel.html).

That said, Robin is correct in stating that this is The Craft Way™.

That leads me to the caution: bear in mind that your service classes "define your plugin’s API, which your plugin (_and other plugins_) can access" ([source](https://docs.craftcms.com/v3/extend/services.html#what-are-services); emphasis added).
Stephen Lewis
CC BY-SA 4.0
2018-08-28T19:24:20.333Z
2018-08-28T19:24:20.333Z
Robin Schambach
<p>I'm trying to familiarize myself with the Craft architecture and I can't understand whether I should be extending <code>craft\base\Component</code> or <code>craft\base\Model</code> for my business logic models. Component seems like a pretty lean class that only adds a few initialization events to Model.</p>

<plugin-development><craft3><models><element>
What's the difference between a Component and a Model in Craft 3?
# What's the difference between a Component and a Model in Craft 3?

(Asked by: username_0 on 2018-08-28)

I'm trying to familiarize myself with the Craft architecture and I can't understand whether I should be extending `craft\base\Component` or `craft\base\Model` for my business logic models. Component seems like a pretty lean class that only adds a few initialization events to Model.

**Tags:** plugin-development, craft3, models, element


---

## 1 answers

### Answer by username_1 on 2018-08-28. Score: 5 | Accepted answer

[Models](https://www.yiiframework.com/doc/guide/2.0/en/structure-models) are classes that contains abstractions of the reality, for example you could have the model car that contains the technical information about it, how many wheels it has and it's brand. Models are usually not supposed to contain any logic. So it's just a "container" with information

[Components](https://www.yiiframework.com/doc/guide/2.0/en/concept-components) are more like services that contains business logic to work with your models, for example the service car would handle the logic to let your car model drive and move and such. Components in Yii2 are mostly (not always) treated as singletons while you want to have many different instances of your models

> **Comments:**
> **username_0**: Thanks for the clarification! I just realized Services in Craft were actually extending Components in Yii. A bit confusing in terminology, but I'm starting to wrap my head around it!  
> **username_2**: A minor caveat, and a caution.  First the caveat: there is a strong argument that [anemic models are an anti-pattern](https://www.martinfowler.com/bliki/AnemicDomainModel.html).  That said, Robin is correct in stating that this is The Craft Way™.  That leads me to the caution: bear in mind that your service classes "define your plugin’s API, which your plugin (_and other plugins_) can access" ([source](https://docs.craftcms.com/v3/extend/services.html#what-are-services); emphasis added).  

---

