3
我仍然在学习使用PHP的作曲家作曲家PSR-4自动加载无法找到文件
我有这样的目录结构:
,这是我composer.json
{
"autoload": {
"psr-4": {
"Kct\\": "lib/"
}
}
}
现在在我的index.php文件中,我正试图在tesdir.php中加载Class tes
<?php
// file: index.php
require __DIR__ . '/vendor/autoload.php';
$x = new \Kct\Tesdir\Tes();
var_dump($x->tes()); //output: 'GET'
我tesdir.php:
<?php
namespace Kct\Tesdir;
class Tes {
public function tes() {
return $_SERVER['REQUEST_METHOD'];
}
}
现在
,如果我在我的本地主机打开的index.php我和这样的错误:
Fatal error: Uncaught Error: Class 'Kct\Tesdir\Tes' not found in /var/www/html/tesComposer/index.php:6 Stack trace: #0 {main} thrown in /var/www/html/tesComposer/index.php on line 6
有人可以解释为什么?
谢谢dud,非常有帮助:)) – Herdy