简体   繁体   中英

Composer autoload, class not found

I get this error: Fatal error: Class 'Handlers\\AuthenticateHandler' not found

My composer.json

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

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\\": "."
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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