php - Composer /WordPress : wp-content directory should or should not be committed

标签 php wordpress git dependencies composer-php

所以我最近开始在基于 this 的 WordPress 上使用 Composer。教程。

这是我的 composer.json 文件:

{
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "wordpress",
                "type": "webroot",
                "version": "4.3",
                "dist": {
                    "type": "zip",
                    "url": "https://github.com/WordPress/WordPress/archive/4.3.zip"
                },
                "require" : {
                    "fancyguy/webroot-installer": "1.0.0"
                }
            }
        }
    ],
    "require": {
        "wordpress": "4.*",
        "fancyguy/webroot-installer": "1.0.0"
    },
    "extra": {
        "webroot-dir": "public/wp",
        "webroot-package": "wordpress"
    }
}

它工作正常,我得到了这个文件夹结构:

enter image description here

正如教程中提到的,我将index.phpwp-config.phpwp-content目录复制到外面wp 目录并替换了路径。

在此之前一切都完美无缺:

Regarding housekeeping with your source code management tool. You’d want to ignore the composer.phar file and public/wp directory. Everything else can be committed and pushed.

所以似乎除了public/wp 文件夹之外,所有内容都可以提交和推送。 (包括 wp-content 文件夹)

这是我不明白的地方。我们必须提交/推送 wp-content 目录,因为它的位置与过去不同,但同时此 wp-content 文件夹包含 pluginsthemes 文件夹,我们的插件和主题将使用 composer 添加,不应该提交/推送吗?

插件和主题将添加到开发环境中,同样使用composer,所以我们不能提交它们,但是它们在应该提交的wp-content目录中?

another类似的教程 wp-content 被设置到 .gitignore 文件中,这意味着它不应该被提交/推送。但如果是这样,谁将(以及如何)将 wp-content 移到开发环境的 wp 目录之外。

有人可以澄清这方面吗?

最佳答案

很高兴您将 wp-content 拆分到一个单独的目录中。

我个人只提交 wp-content 中属于当前项目的项目。另一种思考方式是提交任何不是使用 Composer 添加的内容。

例如,您可能正在处理一个网站,该网站有一个父主题,您正在使用 Composer 将其引入并将保持不变,还有一个子主题,您正在对其进行更改。

在这个例子中,应该提交子主题并忽略父主题,因为您只是更改子主题中的代码。

.gitignore 文件看起来像这样:

# Ignore everything in wp-content
wp-content/*

# Do not ignore the themes directory. This is needed to add the child theme (below)
!wp-content/themes

# Ignore all of the themes directory contents, including the parent theme
wp-content/themes/*

# Do not ignore the child theme
!wp-content/themes/child-theme/

我通常也会对插件做同样的事情。由 Composer 引入的任何插件都会被忽略,但会提交特定于当前项目且您不会在其他地方使用的插件。

希望这会有所帮助。

关于php - Composer /WordPress : wp-content directory should or should not be committed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33822581/

相关文章:

mysql - 在同一个表上使用内连接进行 SQL 排序并重命名列

php - 在 wordpress 中使用带有自定义 SQL 的 WP_Query

git - 如何将 CVS 仓库实时镜像到 Git

javascript - jQuery Read More 容器扩展问题

wordpress - 如何添加或删除 woocommerce 错误消息

php动态访问self::VAR

git - 如何在系统中没有安装git的情况下安装golang包?

git - 如何在 git 中配置多个 CA 证书?

php - 表单验证失败后如何在 codeigniter 中重新填充下拉列表?

PHP: 7 PDO fetch(All) 尝试将类型转换为关联类型