我遇到此错误“致命错误:未捕获的错误:未找到类'Zend \ Uri \ Uri'”

时间:2019-10-09 11:18:34

标签: php zend-framework2 fatal-error zend-framework3

我在这里共享我正在做的一些代码行。我的其他验证器当前正在工作,但是当我转到此路径“ http://localhost/applications/add”时,URI验证器给出此错误“致命错误:未捕获错误:找不到类'Zend \ Uri \ Uri'”。我已经在“ vendor \ zendframework \ zend-validator \ src \ Uri.php”中添加了Zend URI验证器(为此我也共享屏幕截图)。

<?php
use Zend\Filter;
use Zend\InputFilter\Input;
use Zend\InputFilter\InputFilter;
use Zend\Validator;

class ApplicationsController extends Zend_Controller_Action
{
    public function addAction() {

        $inputFilter = new InputFilter();

        $inputFilter->add(
            [
                'name' => 'web_uri',
                'required' => true,
                'filters' => [
                    ['name' => 'StringTrim'],
                    ['name' => 'HtmlEntities']
                ],
                'validators' => [
                    [
                        'name' => 'NotEmpty'
                    ],
                    [
                        'name' => 'Uri'
                    ],
                ],
            ]
        );
)
}
?>

这是“ zendframework \ zend-validator \ src \ Uri.php”的代码

<?php
namespace Zend\Validator;

use Traversable;
use Zend\Uri\Exception\ExceptionInterface as UriException;
use Zend\Uri\Uri as UriHandler;
use Zend\Validator\Exception\InvalidArgumentException;

class Uri extends AbstractValidator
{
}
?>

this is my folders structure where Uri.php is exist

screen shot of error which I am getting

2 个答案:

答案 0 :(得分:1)

Zend/Uri/Uri是验证程序建议的另一个包zendframework/zend-uri的一部分。看看line 44 of zend-uri composer.json

...
    "suggest": {
...
        "zendframework/zend-uri": "Zend\\Uri component, required by the Uri and Sitemap\\Loc validators"
    },
...

要解决此问题,请在项目的根文件夹中执行以下命令:

composer require zendframework/zend-uri

答案 1 :(得分:0)

您尚未在项目中安装zend-uri软件包。 因此,您已经按照link进行安装了。

OR

在项目根目录中运行以下命令。

$ composer require zendframework/zend-uri