dsflxcfuw27742248 2016-08-14 23:12
浏览 40
已采纳

在验证Lib中找不到类验证器

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 :

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


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"
    }
}

the autoload.php code :

<?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)

展开全部

  • 写回答

1条回答 默认 最新

  • dpl74687 2016-08-16 00:47
    关注

    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.

    Use this as your project composer.json:

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

    Then:

    • run composer install,
    • run your script again.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥60 Python+pygame坦克大战游戏开发实验报告
  • ¥15 R语言regionNames()和demomap()无法选中中文地区的问题
  • ¥15 Open GL ES 的使用
  • ¥15 我如果只想表示节点的结构信息,使用GCN方法不进行训练可以吗
  • ¥15 QT6将音频采样数据转PCM
  • ¥15 本地安装org.Hs.eg.dby一直这样的图片报错如何解决?
  • ¥15 下面三个文件分别是OFDM波形的数据,我的思路公式和我写的成像算法代码,有没有人能帮我改一改,如何解决?
  • ¥15 Ubuntu打开gazebo模型调不出来,如何解决?
  • ¥100 有chang请一位会arm和dsp的朋友解读一个工程
  • ¥15 查询优化:A表100000行,B表2000 行,内存页大小只有20页,运行时3页,设计两个表等值连接的最简单的算法
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部