Composer包在安装时复制目录



我有一个本地依赖项,它托管在一个私有的Gitlab repo上。然而,我很难通过Composer将其纳入我的项目中。

我的composer.json:

"require": {
"crmpicco/GolfBundle": "dev-master"
},
"repositories": [
{
"type": "package",
"package": {
"name": "crmpicco/GolfBundle",
"version": "dev-master",
"source": {
"url": "https://git.crmpicco.com/rfc1872/golfbundle.git",
"type": "git",
"reference": "master"
},
"autoload": {
"psr-4": {
"crmpicco\GolfBundle\": ""
}
}
}
}
],

当我在供应商目录中查找时,目录会加倍,而我没有想到,例如。/vendor/crmpicco/GolfBundle/crmpicco/GolfBundle

当我运行composer update crmpiccoGolfBundle时,当Symfony尝试缓存时,我会收到以下错误:clear:

Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache处理更新后cmd事件时终止,出现异常

[RuntimeException]
执行"缓存:清除--无预热"命令时出错:

PHP Fatal error:  Uncaught SymfonyComponentDebugExceptionClassNotFoundException: Attempted   
to load class "crmpiccoGolfBundle from namespace "crmpiccoGolfBundle".         
Did you forget a "use" statement for "crmpiccoGolfBundlecrmpiccoGolfBundle"?   
in /var/www/crmpicco/symfony/app/AppKernel.php:31   

我在composer.json设置中遗漏了什么/做错了什么?

束目录结构:

/crmpicco
/GolfBundle
/Component      
/DependencyInjection
crmpiccoGolfBundle.php

Bundle composer.json:

{
"name": "crmpicco/GolfBundle",
"type": "library",
"description": "A Symfony 2 bundle which provides an easy way to handle billing and subscriptions.",
"license": "MIT", 
"require": {
"php": ">=7.0",
"symfony/config": "~2.8.34",
"symfony/dependency-injection": "~2.8.34",
"symfony/http-kernel": "~2.8.34",
},
"autoload": {
"psr-4": {
"crmpicco\GolfBundle\": ""
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-web-dir": "web",
"symfony-assets-install": "relative"
}
}

对于包含有效composer.json的存储库,不应使用package类型。此类型是为没有composer.json的程序包设计的,因此此文件将被完全忽略,与程序包中的更新相同。

在您的情况下,最好将其定义为git:

"repositories": [
{
"type": "git",
"url": "https://git.crmpicco.com/rfc1872/golfbundle.git"
}
],

好的。正如我所看到的,您在捆绑包的composer.json中有错误的psr-4自动加载配置您必须将其更改为以下内容:

"autoload": {
"psr-4": {
"crmpicco\GolfBundle\": "crmpicco/GolfBundle"
}
}

此外,如果您不想复制目录,请将捆绑包的内容移动到根目录,然后不要更改composer.json内容。目录重复,因为Composer基于name属性创建目录结构,在您的情况下也是crmpicco/GolfBundle

相关内容

  • 没有找到相关文章

最新更新