0
votes

I installed phalcon 3.0.1-14 on an Ubuntu 14.04 box. Also installed Phalcon DevTools (3.0.1). Initially, I enabled the webtools and when I visit that page, some warnings appear all the time:

Cannot bind an instance to a static closure in /home/pish/vendor/phalcon/devtools/scripts/Phalcon/Web/Tools.php
Cannot bind an instance to a static closure in /home/pish/vendor/phalcon/devtools/scripts/Phalcon/Web/Tools/views/index.phtml

I just ignored them and tried to create a model out of an existing table in the database. When I clicked on "Generate" button I get the following error:

Phalcon\Mvc\Dispatcher\Exception: ModelsController handler class cannot be loaded

and the model is not created. I tested creating a controller as well, but a similar error occurred and the controller was not created either.

Finally, I created the model via the console phalcon model users and it was created successfully.

I noticed, though, that the validation function created by the developer tools doesn't work and causes the following error when I try to create a user:

Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\Email given in...

My question is basically, is there something bad with the version of developer tools I installed that causes the problems with the Webtools and the functions that are generated for models/controllers, etc.? Or I might have something wrong in my system?

2

2 Answers

0
votes

Cannot bind an instance to a static closure

https://github.com/phalcon/cphalcon/issues/11029

Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate()

Fixed in the 3.0.x branch (will be released soon)

0
votes

Regarding your second error message:

Catchable fatal error: Argument 1 passed to Phalcon\Mvc\Model::validate() must implement interface Phalcon\ValidationInterface, instance of Phalcon\Mvc\Model\Validator\Email given in...

Model validation has changed in Phalcon 3.0. In Phalcon v2 you had to do

public function validation()
{
    $this->validate(
        new Phalcon\Mvc\Model\Validator\Email(['field' => 'email']);
    );

    if ($this->validationHasFailed() == true) {
        return false;
    }
}

But the Phalcon\Mvc\Model\Validation is deprecated in v3 and you should use Phalcon\Validation instead. Just alter your code to the following:

public function validation()
{
    $validator = new Validation();

    $validator->add(
       'email', //your field name
        new Phalcon\Validation\Validator\Email([
            'model' => $this,
            'message' => 'Please enter a correct email address'
        ])
    );

    return $this->validate($validator);
}

Maybe the DevTools haven't updated this part yet, I am not sure.