[英]PSR-4 autoloading with Composer - Class not found
I'm create composer package with type library
. 我正在使用类型
library
创建composer包。 And trying to require it to Symfony2 project. 并尝试将其用于Symfony2项目。
The package has following composer.json
该软件包具有以下
composer.json
{
"name": "vendor/package-sdk",
"description": "My private package",
"type": "library",
"license": "MIT",
"autoload": {
"psr-4": {"Vendor\\PackageSDK\\": "src/"}
},
"require": {
"php": ">=5.3.3"
}
}
Then I require it to my SF2 project. 然后,将其用于我的SF2项目。
"repositories": [
{
"type": "git",
"url": "git@github.com:me/vendor-package-sdk.git"
},
],
"require": {
...
"vendor/package-sdk": "~0.0.1-alpha1"
...
}
When I calling 当我打电话时
use Vendor\PackageSDK\Client;
...
$client = new Client();
``` ```
And I got fatal error: 而且出现致命错误:
PHP Fatal error: Class 'Vendor\PackageSDK\Client' not found in /path
If I do 如果我做
composer dump-autoload -o
It works, but 它有效,但是
composer dump-autoload
not. 不。
The file vendor/composer/autoload_psr4.php contain: 文件vendor / composer / autoload_psr4.php包含:
'Vendor\\PackageSDK\\' => array($vendorDir . '/vendor/package-sdk/src'),
Could anybody tell me what am I doing wrong? 有人可以告诉我我在做什么错吗?
In composer autoload_classmap.php file I saw the following line 在作曲家的autoload_classmap.php文件中,我看到了以下行
'Vendor\\PackageSDK\\Client' => $vendorDir . 'Vendor \\ PackageSDK \\ Client'=> $ vendorDir。 '/vendor/package-sdk/src/ Cilent .php',
'/ vendor / package-sdk / src / Cilent .php',
So it's just a typo in filename of package 所以这只是包文件名中的错字
Cilent .php should be Client .php Cilent .php应该是Client .php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.