2017-06-02 37 views
0

我們正在嘗試使用作曲家來處理wordpress網站的依賴關係。我想在這些依賴中包含wordpress本身。我正在嘗試將wordpress安裝到項目的根目錄。所有其他插件等正在安裝基於安裝程序路徑正確..作曲家自定義安裝目錄 - 根

我已經嘗試使用fancyguy/webroot安裝程序,但擦拭包安裝到 也試過mnsami/composer-custom-目錄安裝程序,但也抹去目錄。

我有一些根目錄下的文件,我不想刪除 - 比如composer.json,.tfignore和suchlike。

是我必須讓它安裝到/ vendor然後運行安裝後腳本將其移動到我想要的位置的唯一選項?或者是有另一種選擇我缺少

這裏是一個我試圖爲根目錄,安裝

{ 
    "name": "the/name", 
    "description": "description", 
    "repositories": [ 
    { 
     "type": "composer", 
     "url": "https://wpackagist.org" 
    }, 
    { 
     "type": "package", 
     "package": { 
     "name": "wordpress", 
     "type": "webroot", 
     "version": "4.7.5", 
     "dist": { 
      "type": "zip", 
      "url": "https://github.com/WordPress/WordPress/archive/4.7.5.zip" 
     }, 
     "require": { 
      "fancyguy/webroot-installer": "1.0.0" 
     } 
     } 
    } 
    ], 
    "require-dev": { 
    "wpackagist-plugin/query-monitor": "2.13.4", 
    "wordpress": "4.7.5", 
    "fancyguy/webroot-installer": "1.0.0" 
    }, 
    "require": { 
    "wpackagist-plugin/advanced-custom-fields": "4.4.11", 
    ...etc 
    }, 
    "extra": { 
    "webroot-dir": ".", 
    "webroot-package": "wordpress", 
    "installer-paths": { 
     "library/plugins/{$name}": [ "type:wordpress-plugin" ] 
    } 
    }, 
    "scripts": { ...} 
} 

這裏使用的作曲家,自定義目錄安裝的composer.json。

{ 
    "name": "the/name", 
    "description": "description", 
    "repositories": [ 
    { 
     "type": "composer", 
     "url": "https://wpackagist.org" 
    }, 
    { 
     "type": "package", 
     "package": { 
     "name": "wordpress", 
     "type": "library", 
     "version": "4.7.5", 
     "dist": { 
      "type": "zip", 
      "url": "https://github.com/WordPress/WordPress/archive/4.7.5.zip" 
     } 
     } 
    } 
    ], 
    "require-dev": { 
    "mnsami/composer-custom-directory-installer": "1.1.*", 
    "wordpress": "4.7.5" 
    }, 
    "require": { 
    "wpackagist-plugin/advanced-custom-fields": "4.4.11", 
    ...etc 
    }, 
    "extra": { 
    "installer-paths": { 
     "library/plugins/{$name}": [ "type:wordpress-plugin" ], 
     "./": [ "wordpress" ] 
    } 

    }, 
    "scripts": { ... } 
} 

回答

0

我相信這是作曲家安裝程序的工作原理。從閱讀完成後,它會清除舊文件,以確保版本沒有任何交叉污染。它不像一個可以處理差異的git checkout/merge,而是可以根據需要進行乾淨安裝(緩存類型)。

我建議您不要將任何正在創作的文件保存在您正在安裝的文件所在的同一文件夾中,而應採取將所有內容安裝並編譯到分發文件夾的方法。

利用網絡包或吞噬等工具,加上NPM和作曲家來處理所有的編譯,並保留你的分發文件夾作爲可以被吹走和複製的東西。它增加了一些開銷,但允許所有工具進行交互而不會造成文件丟失。

例如我典型的回購看起來如下。使用所有不同的工具,dist完全是gitignored,但是composer和build工具編譯成它。從那裏,如果我想FTP或使用CI/CD我可以,但我有一個乾淨的文件夾,永遠不會存儲,幷包含整個項目,一旦我運行的工具。

/dist 
/src (where any files I'm authoring reside) 
composer.json 
package.json 
gulpfile.js 
etc... 

快速更新到此。一直在玩更多的自己玩。看來composer安裝程序的擴展版本不會安裝在其他目錄之上。我已經做了以下這似乎每次工作(仍然需要部署雖然測試)

"extra": { 
    "installer-types": ["cms-core"], 
    "installer-paths": { 
     "public/wp": ["type:cms-core"], 
     "public/wp-content/plugins/{$name}/": ["type:wordpress-plugin"], 
     "public/wp-content/themes/{$name}/": ["type:wordpress-theme"] 
    } 
}, 
"repositories":[ 
    { 
     "type": "composer", 
     "url": "https://wpackagist.org" 
    }, 
    { 
     "type": "package", 
     "package": { 
      "name": "wordpress", 
      "type": "cms-core", 
      "version": "4.7.5", 
      "dist": { 
       "type": "zip", 
       "url": "https://github.com/WordPress/WordPress/archive/4.7.5.zip" 
      } 
     } 
    } 
], 
"require": { 
    "composer/installers": "^1.3", 
    "oomphinc/composer-installers-extender": "^1.1", 
    "wpackagist-plugin/wordpress-seo": "^4.8", 
    "wordpress": "^4.7" 
}, 
"scripts": { 
    "post-update-cmd": [ 
     "cp -R public/wp/ public && rm -rf public/wp" 
    ] 
}`