简体   繁体   English

作曲家自动加载,找不到类

[英]Composer autoload, class not found

I get this error: Fatal error: Class 'Handlers\\AuthenticateHandler' not found 我收到此错误:致命错误:找不到类'Handlers \\ AuthenticateHandler'

My composer.json 我的composer.json

    {
  "autoload": {
    "psr-4": {"Handlers\\": "/"}
  }
}

AuthenticateHandler.php: AuthenticateHandler.php:

<?php

namespace Handlers;

class AuthenticateHandler
{
    static function handle(){

    }
}

How i use it: 我如何使用它:

require_once "Handlers/vendor/autoload.php";
-----
 \Handlers\AuthenticateHandler::handle();

You should use . 您应该使用. instead of / when referring to the current directory in autoload path. 在自动加载路径中引用当前目录时,请使用/代替/ / actually refers to your root folder. /实际上是指您的根文件夹。

This should fix the issue: 这应该可以解决问题:

"autoload": {
    "psr-4": {
        "Handlers\\": "."
    }
}

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

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