我正在准备 php 库,并决定重新组织目录结构。
一切正常,从这个结构:
我决定搬进:
我重新生成了自动加载(php composer.phar dumpautoload),运行测试并得到:
PHP Fatal error: Class 'Compa\Components\Finder\Objects' not found in /home/mrok/php/top/pac-b-test/tests/Finder/ObjectsTest.php on line 15
PHP Stack trace:
PHP 1. {main}() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/composer/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/composer/bin/phpunit:65
PHP 3. PHPUnit_TextUI_Command->run() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:346
PHP 6. PHPUnit_Framework_TestSuite->run() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->runTest() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 8. PHPUnit_Framework_TestCase->run() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 9. PHPUnit_Framework_TestResult->run() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:769
PHP 10. PHPUnit_Framework_TestCase->runBare() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 11. PHPUnit_Framework_TestCase->runTest() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:824
PHP 12. ReflectionMethod->invokeArgs() /home/mrok/php/top/pac-b-test/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:969
PHP 13. Compa\Components\Test\Finder\ObjectsTest->find() /home/mrok/php/top/pac-b-test/tests/Finder/ObjectsTest.php:0
autload_namespaces 包含:
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Symfony\\Component\\Yaml' => $vendorDir . '/symfony/yaml/',
'Compa\\Components' => $baseDir . '/src/',
);
知道有什么问题吗?我应该更改包含路径吗?我不这么认为,否则每个使用这个库的人都必须这样做。