安装时Composer软件包会复制目录

时间:2018-07-23 03:56:19

标签: php symfony composer-php dependency-management

我有一个本地依赖项,该依赖项托管在私有的Gitlab存储库中。但是,我很难通过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 crmpicco\GolfBundle时,当Symfony尝试进行缓存时,出现以下错误:清除:

脚本Sensio \ Bundle \ DistributionBundle \ Composer \ ScriptHandler :: clearCache处理post-update-cmd事件因异常终止

[RuntimeException]
  执行“'cache:clear --no-warmup'”命令时发生错误:

PHP Fatal error:  Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted   
  to load class "crmpiccoGolfBundle from namespace "crmpicco\GolfBundle".         
  Did you forget a "use" statement for "crmpicco\GolfBundle\crmpiccoGolfBundle"?   
  in /var/www/crmpicco/symfony/app/AppKernel.php:31   

composer.json设置中我缺少什么/做错了什么?

捆绑目录结构:

/crmpicco
   /GolfBundle
      /Component      
      /DependencyInjection
      crmpiccoGolfBundle.php

捆绑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"
  }
}

2 个答案:

答案 0 :(得分:1)

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

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

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

答案 1 :(得分:1)

对于包含有效mongos> sh.shardCollection("mydb.logs", { "tags[0]": 1 } ); { "ok" : 0, "errmsg" : "found missing value in key { : null } for doc: { _id: \"8f0f90bd-e63e-521f-a637-b773f3eefdf0\", tags: [ \"fc4f03a4-0f7b-5cf4-af4e-8b38377a9e34\", \"Converter\" ], date: new Date(1531180801464), account: \"1aff2ce3-b510-525a-86ff-e379fac03f8c\", data: \"Converter has been initialized.\", __v: 0 }" } 的存储库,请勿使用package类型。此类型是为不带composer.json的程序包设计的,因此,与您程序包中的更新一样,此文件将被完全忽略。

对于您而言,最好将其定义为composer.json

git