【发布时间】:2017-06-10 11:58:39
【问题描述】:
这是我的文件结构
├── index.php
├── composer.json
├── src
├── Core
└── Database.php
├── vendor
在我的 composer.json 文件中
"autoload": {
"psr-4": {"Site\\": "src/"}
}
在我的 Database.php 中
namespace Core;
class Database {}
在我的 index.php 中
$db = new Site\Core\Database();
但我收到一个错误:找不到类 'Site\Core\Database'。
我已经运行了composer update 和composer dump-auto -o,但仍然没有成功。我已经查看了这里的许多其他类似问题,但它们没有帮助。
谢谢
【问题讨论】:
-
您的
Database类就在Core命名空间中。更改您的作曲家条目以从src/加载Core或将Site\添加到您的数据库命名空间。
标签: php composer-php