在方面验证库中找不到类验证器 [英] Class validator not found in respect validation Lib

查看:101
本文介绍了在方面验证库中找不到类验证器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Composer的新手,但是我可以从cmd中获取vendorcomposer.lockcomposer.json,然后将它们粘贴到没有Validation_Master文件夹的项目中. 我的项目路径:C:\wamp64\www\php Projects\project 1\(here there are test.php and vendor, composer.lock and composer.json) Validation_Master文件夹路径:C:\wamp64\www\php Projects\Validation_Master 我的代码是:

I'm new in composer but I could get vendor, composer.lock and composer.json from cmd then I paste them to my project without Validation_Master folder. My project Path: C:\wamp64\www\php Projects\project 1\(here there are test.php and vendor, composer.lock and composer.json) Validation_Master folder path: C:\wamp64\www\php Projects\Validation_Master My Code is:

<?php
    require "vendor/autoload.php";
    use Respect\Validation\Validator as v;
    $number = 123;
    v::numeric()->validate($number);
?>

但是上面的代码给了我以下错误:

But the above code gives me the following error :

致命错误:找不到类'Respect \ Validation \ Validator' C:\ wamp64 \ www \ php Projects \ project 1 \ test.php

Fatal error: Class 'Respect\Validation\Validator' not found in C:\wamp64\www\php Projects\project 1\test.php


我做了什么?!?
将Validation_Master文件夹复制到test.php的路径==>(失败)
将Vendor文件夹复制到Validation_Master文件夹的路径,并从那里开始需要==>(失败)
大量处理名称空间,并将名称空间Respect \ Validation添加到代码==>(失败)
有什么问题 ???? 如何使用尊重验证库????请基本回答我(我之前读过文档但没有帮助)
供应商文件夹图像
composer.json代码:


What did I do?!!?
copy Validation_Master folder to the path of test.php ==> (Failed )
copy Vendor folder to the path of Validation_Master folder and required from there ==> (Failed )
Manipulate namespace a lot and add namespace Respect\Validation to the code ==> (Failed )
What's The PROBLEM ???? How Can I use Respect Validation Library ????? Please answer me basically (I read docs before but didn't help)
vendor folder image
composer.json code:

{
    "name": "respect/validation",
    "description": "The most awesome validation engine ever created for PHP",
    "keywords": ["respect", "validation", "validator"],
    "type": "library",
    "homepage": "http://respect.github.io/Validation/",
    "license": "BSD Style",
    "authors": [
        {
            "name": "Respect/Validation Contributors",
            "homepage": "https://github.com/Respect/Validation/graphs/contributors"
        }
    ],
    "require": {
        "php": ">=5.6"
    },
    "require-dev": {
        "egulias/email-validator": "~1.2",
        "malkusch/bav": "~1.0",
        "mikey179/vfsStream": "^1.5",
        "phpunit/phpunit": "~5.3",
        "symfony/validator": "~2.6.9",
        "zendframework/zend-validator": "~2.3"
    },
    "suggest": {
        "ext-bcmath": "Arbitrary Precision Mathematics",
        "ext-mbstring": "Multibyte String Functions",
        "egulias/email-validator": "Strict (RFC compliant) email validation",
        "malkusch/bav": "German bank account validation",
        "symfony/validator": "Use Symfony validator through Respect\\Validation",
        "zendframework/zend-validator": "Use Zend Framework validator through Respect\\Validation",
        "fabpot/php-cs-fixer": "Fix PSR2 and other coding style issues"
    },
    "autoload": {
        "psr-4": {
            "Respect\\Validation\\": "library/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Respect\\Validation\\": "tests/library/"
        }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "2.0-dev"
        }
    },
    "scripts": {
        "test": "./vendor/bin/phpunit"
    }
}

autoload.php代码:

<?php
require_once  __DIR__ . '/composer' . '/autoload_real.php';

return ComposerAutoloaderInit46e0d859a60be6f2acf30ed92a2228ad::getLoader();

我很感激和抱歉,我写了很多书

更新:我的问题类似这篇文章:

I appreciate and sorry that I've written a lot

UPDATE : My problem like this post : Why my autoload.php of composer doesn't work?, but it didn't help
I also run composer dump-autoload in cmd ==> (failed)

推荐答案

在我看来,您好像复制了respect/validation库的composer.json,并尝试将其用作项目的composer.json.这是完全错误的方法.

It looks to me like you copied the composer.json of the respect/validation library, and tried to use it as the composer.json for your project. This is a completely wrong approach.

将此用作您的项目composer.json:

Use this as your project composer.json:

{
  "require": {
    "respect/validation": "^1.0"
  }
}

然后:

  • 运行composer install
  • 再次运行脚本.

这篇关于在方面验证库中找不到类验证器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆