首页 文章

Composer程序包在安装时复制目录

提问于
浏览
1

我有一个本地依赖项,它托管在一个私有的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 crmpicco\GolfBundle 时,当Symfony尝试执行缓存时,我收到以下错误:clear:

脚本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

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

2 回答

  • 1

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

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

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

    好 . 我看到你的包中有错误的 psr-4 autoload配置 composer.json 您必须将其更改为以下内容:

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

    此外,如果您没有't want duplicating of dirs, move your bundle'的内容到根目录,然后不要更改 composer.json 内容 . Dirs重复,因为Composer根据 name 属性创建dir结构,在您的情况下也是 crmpicco/GolfBundle .

相关问题