In the Craft Models documentation example the model extends the BaseModel class. However in the example Events plugin source code the Events_EventModel extends the BaseElementModel.

While poking around in PHPStorm I also noticed other "base model" classes such as:

  • BaseComponentModel
  • BaseElementModel
  • BaseEntryRevisionModel

I also wondered if it makes sense to extend non-base models such as the EntryModel (if you're modeling entry data for example).

1 Answer 1


BaseComponentModel, BaseElementModel and BaseEntryRevisionModel all ultimately end up extending BaseModel, which itself extends Yii's CModel.

I like to think of them, roughly, as beefed up Data Transfer Objects. Primarily useful for transferring data throughout the various layers of Craft (templates, controllers, services, etc.).

Regarding which ones you extend, it depends entirely on what you are trying to do in your plugin and with your Models.

BaseModel is the most "generic" one as far as Craft is concerned that gives you all of the Craft specific attributes of Models.

BaseElementModel is useful if your plugin is dealing with Element Types.

BaseComponentModel is useful if your plugin is dealing with Component Types (tools, widgets, tasks, etc.). You can check the craft/app/enums/ComponentType.php enum for a full list.

And BaseEntryRevisionModel is pretty self explanatory.

And there is nothing stopping you from extending things like Craft's own EntryModel directly, if you need specific features that it has.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.