What is an Event in Yii2?
Because PHP doesn’t contain actual events like JavaScript, event programming isn’t always familiar territory for PHP developers. The only true event in PHP is handling a PHP script’s request (through a direct link or a form submission). The PHP code in that script is performed as a result of that event occurring. In JavaScript, on the other hand, you may have your code watch for and respond to a variety of events (such as a form’s submission, the movement of the cursor, and so on) as long as the browser window is open. Yii adds additional event capability to PHP-based Web sites thanks to the component class. In any language, event handling begins with the declaration “when this event occurs with this thing, call this function.” You can construct your events in Yii, but models have their own set of predefined events to keep an eye on before a model is stored, after a model is saved before a model is verified, and so on (the available events will depend upon the model type)....