We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

construct() is deprecated

My server configuration environment php7.1.2 phalcon3.2.4

I have a question

In ODM,I used Validator

$this->validate(new PresenceOf( array( 'field' => 'proname', 'message' => 'please type product name', ) ));

have a warning

Function Phalcon\Mvc\Model\Validator::__construct() is deprecated

edited Feb '18

You can use either initialize() or onConstruct(). For your use-case it should be initialize()

The initialize() method is only called once during the request, it’s intended to perform initializations that apply for all instances of the model created within the application. If you want to perform initialization tasks for every instance created you can use the onConstruct() method:

https://olddocs.phalcon.io/en/latest/reference/models.html#creating-models