php – 为什么我的composer.json会在作曲家安装后自动删除或丢失?

$composer安装后,一切顺利但是composer.json丢失了(删除?).

这就是,在composer安装之后,composer.json将不再存在.

这很奇怪.

这是我的composer.json:

{
  "repositories": [
    {
      "type": "composer",
      "url": "http://wpackagist.org"
    },
    {
      "type": "package",
      "package": {
        "name": "wordpress",
        "type": "webroot",
        "version": "4.4.1",
        "dist": {
          "type": "zip",
          "url": "https://github.com/WordPress/WordPress/archive/4.4.1.zip"
        },
        "require": {
          "fancyguy/webroot-installer": "1.0.0"
        }
      }
    }
  ],
  "require": {
    "php": ">=5.3.0",
    "wordpress": "4.4.1",
    "fancyguy/webroot-installer": "1.0.0"
  },
  "extra": {
    "webroot-dir": "./",
    "webroot-package": "wordpress"
  }
}

供应商目录和composer.lock仍然存在.

myMBP:testtt erwai$composer install
Loading composer repositories with package information
Installing dependencies (including require-dev)
  - Installing fancyguy/webroot-installer (1.0.0)
    Loading from cache

  - Installing wordpress (4.4.1)
    Loading from cache

Writing lock file
Generating autoload files

myMBP:testtt erwai$ls
composer.lock       wp-blog-header.php  wp-load.php
index.php       wp-comments-post.php    wp-login.php
license.txt     wp-config-sample.php    wp-mail.php
readme.html     wp-content      wp-settings.php
vendor          wp-cron.php     wp-signup.php
wp-activate.php     wp-includes     wp-trackback.php
wp-admin        wp-links-opml.php   xmlrpc.php

myMBP:testtt erwai$ls composer.json
ls: composer.json: No such file or directory

myMBP:testtt erwai$ls composer.lock
composer.lock

myMBP:testtt erwai$ls vendor
autoload.php    composer

> OS:OS X 10.11.2
> PHP:5.5.30
>作曲家:1.0-dev(64b0d721838cdceef679761c5cf69a0d070d14c9)

编辑

我认为在安装wordpress时可能会发生这种情况.

由于wordpress安装在根目录(“webroot-dir”:“./”)中,它似乎清理了所有目录.

有什么想法吗?

最佳答案

Since wordpress is installed in the root directory (“webroot-dir”: “./”), it seems to clean up all the directory.

Composer将ZIP存档提取到您的文件夹中,覆盖其内容.
当Composer完成时,它会添加composer.lock文件和Composer自动加载文件(vendor / autoload.php和vendor / composer / * .php).

这个插件的目的是将Wordpress安装到自定义文件夹中(而不是安装到项目文件夹中):

/ home / user / composer-wp-installer-project with webroot-dir:/var/www/abc.com/wordpress

因此,我们的想法是不安装到项目的根文件夹中.

请尝试一下:

"extra": {
    "webroot-dir": "wordpress",
    "webroot-package": "wordpress"
}

这将为WP创建一个新的文件夹wordpress,并将“installer”内容及其composer.json保存在项目文件夹中.

点赞