【发布时间】:2016-03-27 21:49:48
【问题描述】:
我在 packagist 上创建了一个简单的学习包(tommytest/tommytest)。它安装得很好,但我必须在安装后立即运行“composer dump-autoload -o”。在手动运行转储自动加载之前,我得到了这个:
致命错误:第 5 行的 C:\xampp\htdocs\simple\index.php 中找不到类 'mysqlgridspace\Page'
手动运行 dump-autoload 后它工作正常。安装包时不应该自动处理自动加载设置吗?
这是我的 composer.json(位于:simple/vendor/tommytest/tommytest/composer.json)
{
"name": "tommytest/tommytest",
"type": "library",
"description": "Framework agnostic data grid",
"keywords": ["datagrid","data grid"],
"homepage": "https://github.com/escalibore/tommytest",
"license": "MIT",
"authors": [
{
"name": "Tommy Bert",
"email": "tom@tberthold.com",
"homepage": "http://tberthold.com",
"role": "Developer"
}
],
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"mysqlgridspace\\":"src/"
}
}
}
还有我的类文件(位于:simple/vendor/tommytest/tommytest/src/Mysqlgridmain.class.php)
<?php
namespace mysqlgridspace;
class Page {
public function __construct()
{
echo "hello, i am a page.<br>";
}
}
class Book {
public function __construct()
{
echo "hello, i am a book.<br>";
}
}
【问题讨论】:
标签: php composer-php autoloader packagist