简体   繁体   English

Phalcon框架上的Webtools和开发人员工具问题

[英]Webtools and developer tools issue on Phalcon framework

I installed phalcon 3.0.1-14 on an Ubuntu 14.04 box. 我在Ubuntu 14.04机器上安装了phalcon 3.0.1-14。 Also installed Phalcon DevTools (3.0.1). 还安装了Phalcon DevTools(3.0.1)。 Initially, I enabled the webtools and when I visit that page, some warnings appear all the time: 最初,我启用了Webtools,当我访问该页面时,始终会出现一些警告:

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. 最后,我通过控制台phalcon model users创建了模型,并成功创建了模型。

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.? 我的问题基本上是,我安装的开发人员工具的版本是否存在问题,从而导致Webtools和为模型/控制器等生成的功能出现问题? Or I might have something wrong in my system? 还是我的系统可能有问题?

Cannot bind an instance to a static closure 无法将实例绑定到静态闭包

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

Catchable fatal error: Argument 1 passed to Phalcon\\Mvc\\Model::validate() 可捕获的致命错误:参数1传递给Phalcon \\ Mvc \\ Model :: validate()

Fixed in the 3.0.x branch (will be released soon) 已在3.0.x分支中修复(即将发布)

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... 可捕获的致命错误:传递给Phalcon \\ Mvc \\ Model :: validate()的参数1必须实现接口Phalcon \\ ValidationInterface,Phalcon \\ Mvc \\ Model \\ Validator \\ Email的实例在...中给出

Model validation has changed in Phalcon 3.0. 在Phalcon 3.0中,模型验证已更改。 In Phalcon v2 you had to do 在Phalcon v2中,您必须做

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. 但是在v3中不推荐使用Phalcon\\Mvc\\Model\\Validation ,而应该使用Phalcon\\Validation 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. 我不确定DevTools尚未更新此部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM