move-elevator/humhub-composer-installer

humhub 内部软件的 composer 安装器。

2.0.0 2019-07-31 07:13 UTC

README

Build Status Software License Latest Stable Version Total Downloads

Humhub Composer Installer

此包将 HumHub 版本 1.3.* 安装到项目配置文件 composer.json 中的 web 目录,该目录相对于项目-vendor 目录(humhub: web-dir)。您还可以配置配置目录(humhub: config-dir)。在该目录中,您可以放置项目 index.php、.htaccess 和 protected/yii,它们将被链接到 humhub 的 web 目录。

您还可以配置自己的模块目录(humhub: module-dir)和主题目录(humhub: theme-dir)。这些也将被链接到 humhub 的 web 目录,并且应相对于项目-vendor-dir。

如果您的项目中没有提供配置文件(index.php、protected/yii),此包将安装默认配置文件。这些文件可以在本包的 etc/config 目录中找到。

任何 composer 更新或安装都会重新生成整个 web 目录。生成的符号链接是相对路径,因此可以压缩,例如作为 tar 或 zip 文件。这对于部署或其他项目移动非常重要。

安装 Humhub

将以下行添加到您的项目 composer.json 文件中

  "require": {
    "oomphinc/composer-installers-extender": "^1.1", 
    "bower-asset/select2-bootstrap-theme": "0.1.0-beta.4",
    "humhub/humhub": "v1.2.3",
    "move-elevator/humhub-composer-installer": "~1.0"
  },
  "autoload": {
    "psr-4": {
      "humhub\\": "web/protected/humhub",
      "humhub\\modules\\": "web/protected/modules"
    }
  },
  "repositories": [
    {
      "type": "vcs",
      "url":  "https://github.com/humhub/humhub.git"
    },
    {
      "type": "composer",
      "url": "https://asset-packagist.org"
    }
  ],
  "scripts": {
    "post-update-cmd": [
      "MoveElevator\\Composer\\Installer::initialize"
    ],  
    "post-install-cmd": [
      "MoveElevator\\Composer\\Installer::initialize"
    ]  
  },
  "extra": {
    "humhub": {
      "web-dir": "../web",
      "config-dir": "../etc/config",
      "module-dir": "../modules",
      "theme-dir": "../themes"
    },
    "installer-types": [
      "bower-asset", 
      "npm-asset"
    ],
    "installer-paths": {
      "vendor/bower/{$name}/": ["type:bower-asset"],
      "vendor/npm/{$name}/": ["type:npm-asset"]
    },
  }

此示例使用 https://asset-packagist.org/ 安装 bower 和 npm 资产。如果您之前使用了 fxpio/composer-asset-plugin,请禁用该插件以避免问题。只需将以下内容添加到 composer.json 即可

config": {
  "fxp-asset": {
    "enabled": false
  }
},

有关详细信息,请访问 https://asset-packagist.org/site/about

检查

在当前包根目录中运行每个命令。

执行 PHPUnit 测试

./vendor/bin/phpunit.phar -c ./phpunit.xml --testdox

执行 PHPStan 检查

./vendor/bin/phpstan.phar analyse -l max -c ./phpstan.neon ./src/

执行 phpcs 修复器

./vendor/bin/phpcs-fixer.phar fix ./src 

执行 PSR2 的 checkstyle

./vendor/bin/phpcs.phar ./src --standard=PSR2 

故障排除

  • 此包无法处理项目根目录之外的 vendor、web、config、theme 或模块目录。
  • 此包不会创建 uploads 目录。部署后,您可以链接全局目录到 uploads,以防止丢失所有之前的上传。
  • 从在线市场更新或下载的内容将下载到 vendor/humhub/humhub/protected/modules 文件夹,并且应该移动到您的原始 module-dir
    • 目前,在 humhub 中无法重新配置这些下载文件夹。
    • 安装新模块并将其移动到原始 module-dir 后,您应重新运行此包的安装脚本。如果您使用上面的示例,可以运行 composer run-script post-update-cmd

待办事项

  • 测试和实现 Windows 系统的安装