我们试图使用composer来处理wordpress站点的依赖关系。我想将wordpress本身包含在这些依赖项中。我正在尝试安装wordpress到项目的根目录。所有其他插件等都是基于安装程序路径正确安装的。
我试过使用fancyguy/webroot-installer,但这会擦除包安装的目录,也会尝试mnsami/composer-定制目录-installer,但也会擦除目录。
根目录中有许多我不想删除的文件,比如composer.json for one、.tfignore和诸如此类的文件。
是唯一的选择,我必须让它安装到/vendor,然后运行一个后安装脚本,以将它移动到我想要的地方?或者还有另一个选择,我错过了
这是我为webroot-installer所做的尝试。
{
"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-定制目录-安装程序的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": { ... }
}发布于 2017-06-04 19:45:03
我相信作曲家安装程序就是这样工作的。从阅读中,我已经做了删除旧文件,以确保没有任何交叉污染的版本。这不像处理差异的git签出/合并,而是在需要时进行干净的安装(缓存类型)。
我建议不要将您正在创建的任何文件保存在您正在安装的文件夹中,而是采用将所有内容安装并编译到分发文件夹中的方法。
利用诸如web或gulp之类的工具,再加上NPM和composer来处理所有的编译,并将您的分发文件夹保持为可以被吹走和复制的东西。它增加了一些开销,但允许所有工具进行交互,而不会导致文件丢失。
例如,我的典型回复如下所示。有了所有不同的工具之后,dist就完全被接受了,但是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"
]
}`发布于 2019-09-20 09:44:22
对于任何试图使用Wordpress和Composer的新访问者,请使用自定义Composer安装程序查看https://github.com/johnpbloch/wordpress的实现。详细信息和示例可以在https://composer.rarst.net/上找到,但其要点是:
composer.json:
{
"name" : "my/wordpress-project",
"description" : "Test project for WordPress stack via Composer",
"type" : "project",
"repositories": [
{
"type": "composer",
"url" : "https://wpackagist.org"
}
],
"config" : {
"vendor-dir": "wp-content/vendor"
},
"require" : {
"johnpbloch/wordpress" : ">=5",
"wpackagist-plugin/a-fresher-cache" : "*",
"wpackagist-plugin/core-control" : "*",
"wpackagist-plugin/monster-widget" : "*",
"wpackagist-plugin/theme-check" : "*",
"wpackagist-plugin/user-switching" : "*",
"wpackagist-plugin/wcm-user-language-switcher" : "*"
},
"extra" : {
"installer-paths" : {
"wp-content/plugins/{$name}/": ["type:wordpress-plugin"]
"wp-content/themes/{$name}/": ["type:wordpress-theme"]
}
"wordpress-install-dir": "wp"
}
}这将把Wordpress安装到/wp文件夹中。您将需要修改您的.htaccess以适应需要,详见此处:https://wordpress.org/support/article/giving-wordpress-its-own-directory/
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/wp/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wp/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ wp/index.php [L]
</IfModule>https://stackoverflow.com/questions/44331421
复制相似问题