我正在使用作曲家,我有以下类图:
return array(
'Wit\\Cache\\CacheAdapterInterface' => $baseDir . '/src/Wit/Cache/CacheAdapterInterface.php',
'Wit\\Cache\\CacheManager' => $baseDir . '/src/Wit/Cache/CacheManager.php',
'Wit\\Cache\\FileAdapter' => $baseDir . '/src/Wit/Cache/FileAdapter.php',
'Wit\\Cache\\RedisAdapter' => $baseDir . '/src/Wit/Cache/RedisAdapter.php',
'Wit\\Request\\Request' => $baseDir . '/src/Wit/Request/Request.php',
'Wit\\Zenpoint\\ZenpointUser' => $baseDir . '/src/Wit/Zenpoint/ZenpointUser.php',
'Wit\\Zenpoint\\ZenpointConfig' => $baseDir . '/src/Wit/Zenpoint/ZenpointConfig.php',
'Wit\\Zenpoint\\ZenpointCarrello' => $baseDir . '/src/Wit/Zenpoint/ZenpointCarrello.php',
'Wit\\Zenpoint\\ZenpointAcquisitions' => $baseDir . '/src/Wit/Zenpoint/ZenpointAcquisitions.php',
'Wit\\Zenpoint\\ZenpointAcquisition' => $baseDir . '/src/Wit/Zenpoint/ZenpointAcquisition.php',
'Wit\\Cart\\ZipCodeChecker' => $baseDir . '/src/Wit/Cart/ZipCodeChecker.php',
'Wit\\Cart\\ZipCodeLoader' => $baseDir . '/src/Wit/Cart/ZipCodeLoader.php',
'Wit\\Complimentary\\OmaggioOrdine' => $baseDir . '/src/Wit/Complimentary/OmaggioOrdine.php',
'Wit\\Complimentary\\PacchettoOmaggio' => $baseDir . '/src/Wit/Complimentary/PacchettoOmaggio.php',
'Wit\\Complimentary\\ProdottiAScelta' => $baseDir . '/src/Wit/Complimentary/ProdottiAScelta.php',
'Wit\\Complimentary\\OmaggioLoader' => $baseDir . '/src/Wit/Complimentary/OmaggioLoader.php',
'Wit\\Complimentary\\PacchettoLoader' => $baseDir . '/src/Wit/Complimentary/PacchettoLoader.php',
'Wit\\Complimentary\\ProdottiASceltaLoader' => $baseDir . '/src/Wit/Complimentary/ProdottiASceltaLoader.php',
'Wit\\Complimentary\\ProdottiLoader' => $baseDir . '/src/Wit/Complimentary/ProdottiLoader.php',
);
然后我在文件中有以下内容:use WIT\Complimentary\OmaggioLoader;
问题是PHP说找不到类:
Fatal error: Class 'WIT\ComplimentaryProducts\OmaggioLoader' not found.
我首先想到的是路径错了,但似乎并非如此。所以我试着看看Composer ClassLoader.php文件中发生了什么,并转储了以下内容:
var_dump($class); //string(31) "WIT\Complimentary\OmaggioLoader"
var_dump(array_keys($this->classMap)); //[15]=> string(31) "Wit\Complimentary\OmaggioLoader"
var_dump(array_key_exists($class, $this->classMap)); //bool(false)
var_dump($this->classMap[$class]); //NULL
var_dump($this->classMap['Wit\\Complimentary\\OmaggioLoader']);//string(69) "/path/to/Wit/Complimentary/OmaggioLoader.php"
那么,如果密钥正确,为什么PHP无法找到数组元素?为什么我手动插入它,PHP会找到它吗?
答案 0 :(得分:2)
PHP中的类名称不区分大小写,而数组键则不区分大小写。他们有不同的开端。