"Behaviors" enlighten my mind on this

can you please enlighten my mind about Behaviros , I could not understand what is the purpose on this in yii,

Thank you in advance.

Read the last example (TimeStampBehavior) in the guide here http://www.yiiframework.com/doc-2.0/guide-concept-behaviors.html it is probably the clearest example.

A behavior is a way of dynamically extending the behavior of a class and can be attached and detached at runtime without modifying the class you are extending. The behavior adds additional properties to the parent class so that the parent magically adds new functions. If a behavior has a function newFunction() and is attached to a parent class, you can now call:


A Behavior can be part of an inheritance chain so it can be more complicated than something like a trait. It is also able to listen to (and therefore modify) the parent classes response to certain events.