命名空间找不到 class
Namespace cant find class
我尝试使用 composer 将供应商包包含到我的项目中,然后使用名称空间。
包裹 github link: https://github.com/Veltix/passgate
我的项目使用 Slim 4 框架。
我尝试注册时遇到的错误:
Fatal error: Uncaught Error: Class 'Veltix\PassGate' not found in
/path/to/controller/AuthController.php
on line 68
Error: Class 'Veltix\PassGate' not found in
/path/to/controller/AuthController.php
on line 68
我的代码如下所示:
namespace App\Controllers\Auth;
...
use Veltix\PassGate;
...
class AuthController extends Controller
{
...
public function postSignUp($request, $response)
{
...
$user = User::create([
..
'password' => PassGate::hash($data['password']), // 68 Line error
]);
}
}
您的自动加载规则不正确 - 您指定 src
目录映射到 Veltix
命名空间,但所有 类 内部都使用 Veltix\PassGate
命名空间。将您的自动加载规则更改为:
"autoload": {
"psr-4": {
"Veltix\PassGate\": "src/"
}
}
我尝试使用 composer 将供应商包包含到我的项目中,然后使用名称空间。 包裹 github link: https://github.com/Veltix/passgate
我的项目使用 Slim 4 框架。
我尝试注册时遇到的错误:
Fatal error: Uncaught Error: Class 'Veltix\PassGate' not found in /path/to/controller/AuthController.php on line 68
Error: Class 'Veltix\PassGate' not found in /path/to/controller/AuthController.php on line 68
我的代码如下所示:
namespace App\Controllers\Auth;
...
use Veltix\PassGate;
...
class AuthController extends Controller
{
...
public function postSignUp($request, $response)
{
...
$user = User::create([
..
'password' => PassGate::hash($data['password']), // 68 Line error
]);
}
}
您的自动加载规则不正确 - 您指定 src
目录映射到 Veltix
命名空间,但所有 类 内部都使用 Veltix\PassGate
命名空间。将您的自动加载规则更改为:
"autoload": {
"psr-4": {
"Veltix\PassGate\": "src/"
}
}