Composer将git repo安装到自定义路径(Wordpress主题)

时间:2016-07-31 10:47:11

标签: wordpress git composer-php

我有一个托管在Bitbucket上的自定义Wordpress主题,当我运行composer install时,我想将其安装到Wordpress的/ themes目录中。

我玩过不同的回购'类型',例如vcs,package等,到目前为止我尝试过的所有内容都会出错。

这是我的(不工作)composer.json文件的示例:

{
  "authors": [
{
  "name": "Joe Bloggs",
  "homepage": "http://www.example.com/"
}
],
 "keywords": [
 "wordpress", "composer", "wp"
],
 "config": {
 "secure-http": false
},
 "repositories": [
  {
   "type": "composer",
   "url": "http://wpackagist.org"
  },
  {
   "type": "package",
   "package": {
    "name": "wordpress/wordpress",
    "version": "4.5.3",
    "type": "webroot",
    "dist": {
      "type": "zip",
      "url": "https://wordpress.org/wordpress-4.5.3.zip"
    },
    "require" : {
      "fancyguy/webroot-installer": "1.1.0"
    }
  }
 },
 {
  "type": "vcs",
  "url": "https://bitbucket.org/gurtfrobe/plunderscores.git"
 }
],
 "require": {
 "php": ">=5.3.2",
 "wordpress/wordpress": "4.5.3",
 "fancyguy/webroot-installer": "1.1.0",
 "composer/installers": "v1.0.12",
 "gurtfrobe/plunderscores": "1.0.1"
},
"extra": {
 "installer-paths": {
  "wp/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
  "wp/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
  "wp/wp-content/themes/{$name}/": ["type:wordpress-theme"]
 },
  "webroot-dir": "wp",
  "webroot-package": "wordpress/wordpress"
 }
}

我也试过以下但没有运气:

{
  "type": "package",
  "package": {
    "name": "gurtfrobe/plunderscores.git",
    "version": "1.0.1",
    "type": "wordpress-theme",
    "source": {
      "url": "https://bitbucket.org/gurtfrobe/plunderscores.git",
      "type": "vcs",
      "reference": "master"
    }
  }
},

有没有办法在不将我的主题提交给wpackagist的情况下实现这一目标?

1 个答案:

答案 0 :(得分:0)

我用this article解决了这个问题。

请记住在更新composer.json文件后推送最新版本的标签。否则,Composer仍会尝试下载以前的版本。