作曲家 无法在供应商内部运行工具(PHP-Auth/delight-im)



我正在尝试运行此密码身份验证 https://github.com/delight-im/PHP-Auth#creating-a-new-instance

我遵循他们的教程,也遵循作曲家的教程。

目录:

Main
   |
   ->src
   |   |
   |   ->tools
   |         |
   |         ->authentication
   |         |
   |         ->db
   |
   ->vendor 

作曲家

 {
"name": "***",
"autoload": {
    "psr-4": {
        "Source\": "src/"
    }
},
"authors": [
    {
        "name": "***",
        "email": "***"
    }
],
"require": {
    "delight-im/auth": "dev-master",
    "cboden/ratchet": "^0.4",
    "laravel/laravel": "^5.8",
    "twig/twig":"^2.0",
}

}

身份验证文件夹中的文件:

require_once "../../../vendor/autoload.php";
use Sourcetoolsdb;
$dbConfig = new dbdbconfig("users");
$credentials = $dbConfig->setDb();
$pdo_connection =  new PDO("mysql:host=$localhost;dbname=$database_schema",
                   $credentials["UserName"], $credentials["PassWord"]);
$auth = new DelightAuthAuth($pdo_connection);

数据库文件夹中的文件

namespace Sourcetoolsdb;
class dbconfig  
{
  .....
}

我可以使用 Source\tools\db; 来定义 dbconfig,所以我想自动加载正在为此工作。

但是当尝试使用这行代码时$auth = new \Delight\Auth\Auth($pdo_connection(;我收到以下错误:致命错误:未捕获错误:在 中找不到类"Delight\Auth\Auth"(为隐私而删除了目录(/src/tools/authentication/validate_login_credentials.php:17 堆栈跟踪:#0 {main} 抛入

我是命名空间/作曲家的新手,请原谅我对此的无知。

有谁知道如何解决此错误?

我刚刚尝试过,它以这种方式工作,在顶部

require __DIR__ . '/vendor/autoload.php';

之后的数据库配置

$db = new PDO('mysql:dbname=my-database;host=localhost;charset=utf8mb4', 'my-username', 'my-password');
$auth = new DelightAuthAuth($db);
echo get_class($auth);

没有错误,请仔细检查您的供应商自动加载文件,似乎您输入了错误的路径。

使用以下方法更新作曲家文件

"require": {
    "delight-im/auth": "dev-master", // "delight-im/auth": "^8.1"
    "cboden/ratchet": "^0.4",
    "laravel/laravel": "^5.8",
    "twig/twig":"^2.0",
 }

取代

"delight-im/auth": "dev-master",

"delight-im/auth": "^8.1"

保存并执行编辑器更新命令。

最新更新