Title: WP Composer Sync
Author: sharelink
Published: <strong>2018 年 7 月 26 日</strong>
Last modified: 2018 年 7 月 26 日

---

搜索插件

**该插件尚未通过WordPress的最新3个主要版本进行测试**。 当与较新版本的WordPress一起
使用时，可能不再受到维护或支持，并且可能会存在兼容性问题。

![](https://s.w.org/plugins/geopattern-icon/wp-composer-sync.svg)

# WP Composer Sync

 作者：[sharelink](https://profiles.wordpress.org/harmonicnewmedia/)

[下载](https://downloads.wordpress.org/plugin/wp-composer-sync.zip)

 * [详情](https://cn.wordpress.org/plugins/wp-composer-sync/#description)
 * [评价](https://cn.wordpress.org/plugins/wp-composer-sync/#reviews)
 *  [安装](https://cn.wordpress.org/plugins/wp-composer-sync/#installation)
 * [开发进展](https://cn.wordpress.org/plugins/wp-composer-sync/#developers)

 [支持](https://wordpress.org/support/plugin/wp-composer-sync/)

## 描述

WP Composer Sync is a WordPress plugin that keeps a WordPress installation’s composer.
json synchronised with the plugins installed.

### Usage

Once installed the plugin should be largely set and forget, however there a couple
of gotchas.

1) Commercial plugins that are not available from the WordPress.org plugins repository**
will still be added** you will need to manually modify the repository (eg. wpackagist,
wp-premium or using a custom installer or repository) or add your custom plugins
first. WP Composer Sync will then honor these repositories and keep them synchronised
as well.
 2) When composer installs a package, it completely empties the target 
directory before installing the new files. As such, the WordPress path should be
designated for WordPress core files only, as anything else (e.g. plugins, themes,
and wp-config.php) will be wiped away on install or update. It is recommended that
you _keep your wp-config.php file in the parent directory of the WordPress path_(
WordPress can find it there automatically) and _replace the wp-content directory
with a symlink_ to your real wp-content folder. See [link](https://github.com/balbuf/composer-wp)
for more details. 3) Compposer require versioning wildcards (eg. *, 1.*, etc) will
not be honoured (as WordPress does not adhere to this). They will be replaced by
the exact version number in use by WordPress.

### About

### Why?

Composer is a great way to manage WordPress and its plugins. However in real life
it runs the risk of becoming outdated with the actual contents of the website when
admin users are installing plugins via wp-admin or S/FTP.

### How?

Using WordPress’s “plugins_loaded” action and [link](https://github.com/balbuf/composer-wp),
this plugin will check your composer.json file for any outdated or unfound plugins
and will automatically add them to the require section.

#### Roadmap

The plugin is production ready however there are some additional functions and features
which will be added in the future:

1) Add ability to select bewteen https://github.com/balbuf/composer-wp and wpackagist

2) Currently only syncs plugin and wordpress core, add ability to sync themes 3)
Research some ways to monitor plugin-uploads and changes more effectively (eg. [link](https://codex.wordpress.org/Plugin_API/Action_Reference/upgrader_process_complete)
[link](https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/class-plugin-upgrader.php),
[link](https://www.sitepoint.com/wordpress-plugin-updates-right-way/) and [link](https://codex.wordpress.org/Creating_Tables_with_Plugins#Adding_an_Upgrade_Function)
or Transients [link](https://code.tutsplus.com/tutorials/a-guide-to-the-wordpress-http-api-automatic-plugin-updates--wp-25181)
[link](https://stackoverflow.com/questions/32196219/my-plugin-not-updating-properly-issue-with-upgrader-process-complete/50914655#50914655)
or [link](https://wordpress.stackexchange.com/questions/123732/get-latest-plugin-version-from-wp-api))

## 安装

Regardsless of installation method the machine where you are running WordPress requires
Subversion to be installed to allow access to WordPress’s SVN repositories. On *
NIX based servers you can simply:

    ```
    `
    ```

apt -yq install subversion
 `

### New WordPress Install

You can use composer to create your new WordPress instance and include WP Composer
Sync. In the root of your project folder simply create a **composer.json** file 
containing:

    ```
    `
    ```

{
 “name”: “The name of your WordPress site”, “extra”: { “composer-wp”: { “repositories”:[],“
vendors”: {}, “installer”: { “wordpress-path”: “web” } } }, “require”: { “wordpress/
wordpress”: “^4.9.7”, “wordpress-plugin/wp-composer-sync”: “*” }, “scripts”: { “
pre-cmd”: [ “composer global require balbuf/composer-wp && composer global update
balbuf/composer-wp” ], “pre-install-cmd”: “@pre-cmd”, “pre-update-cmd”: “@pre-cmd”}}`

This will install wordpress in a web/ sub-directory (recommended, but you can change
the web root by modifying the “wordpress-path”). It will also globally install [link](https://github.com/balbuf/composer-wp).

### Existing WordPress Install

If you wish to install WP Composer Sync into an existing (composer managed) WordPress
install start by installing [link](https://github.com/balbuf/composer-wp):

    ```
    `
    ```

$ composer global require balbuf/composer-wp
 `

Now you need to add WP Composer Sync to your WordPress install either via wp-admin
or via composer:

    ```
    `
    ```

$ composer global require wordpress/wp-composer-sync
 `

## 常见问题

  Installation Instructions

Regardsless of installation method the machine where you are running WordPress requires
Subversion to be installed to allow access to WordPress’s SVN repositories. On *
NIX based servers you can simply:

    ```
    `
    ```

apt -yq install subversion
 `

### New WordPress Install

You can use composer to create your new WordPress instance and include WP Composer
Sync. In the root of your project folder simply create a **composer.json** file 
containing:

    ```
    `
    ```

{
 “name”: “The name of your WordPress site”, “extra”: { “composer-wp”: { “repositories”:[],“
vendors”: {}, “installer”: { “wordpress-path”: “web” } } }, “require”: { “wordpress/
wordpress”: “^4.9.7”, “wordpress-plugin/wp-composer-sync”: “*” }, “scripts”: { “
pre-cmd”: [ “composer global require balbuf/composer-wp && composer global update
balbuf/composer-wp” ], “pre-install-cmd”: “@pre-cmd”, “pre-update-cmd”: “@pre-cmd”}}`

This will install wordpress in a web/ sub-directory (recommended, but you can change
the web root by modifying the “wordpress-path”). It will also globally install [link](https://github.com/balbuf/composer-wp).

### Existing WordPress Install

If you wish to install WP Composer Sync into an existing (composer managed) WordPress
install start by installing [link](https://github.com/balbuf/composer-wp):

    ```
    `
    ```

$ composer global require balbuf/composer-wp
 `

Now you need to add WP Composer Sync to your WordPress install either via wp-admin
or via composer:

    ```
    `
    ```

$ composer global require wordpress/wp-composer-sync
 `

## 评价

此插件暂无评价。

## 贡献者及开发者

「WP Composer Sync」是开源软件。 以下人员对此插件做出了贡献。

贡献者

 *   [ sharelink ](https://profiles.wordpress.org/harmonicnewmedia/)

[帮助将「WP Composer Sync」翻译成简体中文。](https://translate.wordpress.org/projects/wp-plugins/wp-composer-sync)

### 对开发感兴趣吗?

您可以[浏览代码](https://plugins.trac.wordpress.org/browser/wp-composer-sync/)，
查看[SVN仓库](https://plugins.svn.wordpress.org/wp-composer-sync/)，或通过[RSS](https://plugins.trac.wordpress.org/log/wp-composer-sync/?limit=100&mode=stop_on_copy&format=rss)
订阅[开发日志](https://plugins.trac.wordpress.org/log/wp-composer-sync/)。

## 更新日志

#### 1.0

 * Initial version

## 额外信息

 *  版本 **1.0**
 *  最后更新：**8 年前**
 *  活跃安装数量 **不到10**
 *  WordPress 版本 ** 4.6 或更高版本 **
 *  已测试的最高版本为 **4.7.33**
 *  PHP 版本 ** 7.0 或更高版本 **
 *  语言
 * [English (US)](https://wordpress.org/plugins/wp-composer-sync/)
 * 标签
 * [composer](https://cn.wordpress.org/plugins/tags/composer/)
 *  [高级视图](https://cn.wordpress.org/plugins/wp-composer-sync/advanced/)

## 评级

尚未提交反馈。

[Your review](https://wordpress.org/support/plugin/wp-composer-sync/reviews/#new-post)

[查看全部评论](https://wordpress.org/support/plugin/wp-composer-sync/reviews/)

## 贡献者

 *   [ sharelink ](https://profiles.wordpress.org/harmonicnewmedia/)

## 支持

有话要说吗？是否需要帮助？

 [查看支持论坛](https://wordpress.org/support/plugin/wp-composer-sync/)