找不到类'Respect \ Validation \ Validator'

时间:2017-05-19 08:06:59

标签: php slim

您好我在使用SLIM时遇到的这个错误真的需要帮助。我收到这个错误:

Type: Error
Message: Class 'Respect\Validation\Validator' not found
File: /storage/content/90/223690/marbleuf.se/public_html/cart/app/Validation/Forms/OrderForm.php
Line: 12

以下是来自OrderForm.php的代码:

<?php

namespace Cart\Validation\Forms;

use Respect\Validation\Validator as v;

class OrderForm
{
    public static function rules()
    {
        return [
            'email' => v::email(),
            'name' => v::alpha(' '),
            'address1' => v::alnum(' -'),
            'address2' => v::optional(v::alnum(' -')),
            'city' => v::alnum(' '),
            'postal_code' => v::alnum(' '),
        ];
    }
}

1 个答案:

答案 0 :(得分:0)

根据我的假设,您的使用声明应为以下内容

use Cart\Validation\Validator as v;

不是

use Respect\Validation\Validator as v;

请参阅此参考(如果我有正确的代码库)https://github.com/raniesantos/slim-cart/blob/master/app/Validation/Validator.php