基于 Composer 卸载软件包

1、查看 composer.json,准备卸载软件包:Moontoast Math Library

    "require": {
        "php": ">=7.2.0",
        "yiisoft/yii2": "~2.0.6",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
        "flow/jsonpath": "^0.4.0",
        "yiisoft/yii2-httpclient": "*",
        "yiisoft/yii2-redis": "^2.0",
        "yii2tech/ar-softdelete": "^1.0",
        "hprose/hprose-yii": "^2.0",
        "wartron/yii2-uuid": "dev-master",
        "mito/yii2-sentry": "~1.0.0",
        "yiisoft/yii2-queue": "^2.3",
        "intervention/image": "^2.5",
        "sam-it/yii2-urlsigner": "^2.0",
        "nicolab/php-ftp-client": "^1.5",
        "moontoast/math": "^1.2"
    },

2、使用 help 获取相关命令:remove 的帮助信息,参考网址:https://getcomposer.org/doc/03-cli.md#remove

PS E:/wwwroot/channel-pub-api> composer
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ // __ `__ // __ // __ // ___/ _ // ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
/____//____/_/ /_/ /_/ .___//____/____//___/_/
                    /_/
Composer version 1.9.2 2020-01-14 16:30:31

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display this help message
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi                     Force ANSI output
      --no-ansi                  Disable ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and
3 for debug

Available commands:
  about                Shows the short information about Composer.
  archive              Creates an archive of this composer package.
  browse               Opens the package's repository URL or homepage in your browser.
  check-platform-reqs  Check that platform requirements are satisfied.
  clear-cache          Clears composer's internal package cache.
  clearcache           Clears composer's internal package cache.
  config               Sets config options.
  create-project       Creates new project from a package into given directory.
  depends              Shows which packages cause the given package to be installed.
  diagnose             Diagnoses the system to identify common errors.
  dump-autoload        Dumps the autoloader.
  dumpautoload         Dumps the autoloader.
  exec                 Executes a vendored binary/script.
  global               Allows running commands in the global composer dir ($COMPOSER_HOME).
  help                 Displays help for a command
  home                 Opens the package's repository URL or homepage in your browser.
  i                    Installs the project dependencies from the composer.lock file if present, or falls back on the co
mposer.json.
  info                 Shows information about packages.
  init                 Creates a basic composer.json file in current directory.
  install              Installs the project dependencies from the composer.lock file if present, or falls back on the co
mposer.json.
  licenses             Shows information about licenses of dependencies.
  list                 Lists commands
  outdated             Shows a list of installed packages that have updates available, including their latest version.
  prohibits            Shows which packages prevent the given package from being installed.
  remove               Removes a package from the require or require-dev.
  require              Adds required packages to your composer.json and installs them.
  run                  Runs the scripts defined in composer.json.
  run-script           Runs the scripts defined in composer.json.
  search               Searches for packages.
  self-update          Updates composer.phar to the latest version.
  selfupdate           Updates composer.phar to the latest version.
  show                 Shows information about packages.
  status               Shows a list of locally modified packages, for packages installed from source.
  suggests             Shows package suggestions.
  u                    Upgrades your dependencies to the latest version according to composer.json, and updates the comp
oser.lock file.
  update               Upgrades your dependencies to the latest version according to composer.json, and updates the comp
oser.lock file.
  upgrade              Upgrades your dependencies to the latest version according to composer.json, and updates the comp
oser.lock file.
  validate             Validates a composer.json and composer.lock.
  why                  Shows which packages cause the given package to be installed.
  why-not              Shows which packages prevent the given package from being installed.
PS E:/wwwroot/channel-pub-api> composer remove --help
Usage:
  remove [options] [--] <packages> (<packages>)...

Arguments:
  packages                           Packages that should be removed.

Options:
      --dev                          Removes a package from the require-dev section.
      --no-progress                  Do not output download progress.
      --no-update                    Disables the automatic update of the dependencies.
      --no-scripts                   Skips the execution of all scripts defined in composer.json file.
      --update-no-dev                Run the dependency update with the --no-dev option.
      --update-with-dependencies     Allows inherited dependencies to be updated with explicit dependencies. (Deprecrate
d, is now default behavior)
      --no-update-with-dependencies  Does not allow inherited dependencies to be updated with explicit dependencies.
      --ignore-platform-reqs         Ignore platform requirements (php & ext- packages).
  -o, --optimize-autoloader          Optimize autoloader during autoloader dump
  -a, --classmap-authoritative       Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`
.
      --apcu-autoloader              Use APCu to cache found/not-found classes.
  -h, --help                         Display this help message
  -q, --quiet                        Do not output any message
  -V, --version                      Display this application version
      --ansi                         Force ANSI output
      --no-ansi                      Disable ANSI output
  -n, --no-interaction               Do not ask any interactive question
      --profile                      Display timing and memory usage information
      --no-plugins                   Whether to disable plugins.
  -d, --working-dir=WORKING-DIR      If specified, use the given directory as working directory.
      --no-cache                     Prevent use of the cache
  -v|vv|vvv, --verbose               Increase the verbosity of messages: 1 for normal output, 2 for more verbose output
and 3 for debug

Help:
  The remove command removes a package from the current
  list of installed packages

  php composer.phar remove

  Read more at https://getcomposer.org/doc/03-cli.md#remove

3、remove 命令从当前目录中的 composer.json 文件中删除依赖的软件包关系后,将卸载关系所对应的软件包及其依赖包,如图1

remove 命令从当前目录中的 composer.json 文件中删除依赖的软件包关系后,将卸载关系所对应的软件包及其依赖包

图1

PS E:/wwwroot/channel-pub-api> composer remove moontoast/math
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 0 updates, 3 removals
  - Removing phpseclib/phpseclib (2.0.23)
  - Removing phpseclib/bcmath_compat (1.0.4)
  - Removing moontoast/math (1.2.1)
Writing lock file
Generating autoload files

4、查看 composer.json,已删除依赖的软件包关系:”moontoast/math”: “^1.2”

    "require": {
        "php": ">=7.2.0",
        "yiisoft/yii2": "~2.0.6",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
        "flow/jsonpath": "^0.4.0",
        "yiisoft/yii2-httpclient": "*",
        "yiisoft/yii2-redis": "^2.0",
        "yii2tech/ar-softdelete": "^1.0",
        "hprose/hprose-yii": "^2.0",
        "wartron/yii2-uuid": "dev-master",
        "mito/yii2-sentry": "~1.0.0",
        "yiisoft/yii2-queue": "^2.3",
        "intervention/image": "^2.5",
        "sam-it/yii2-urlsigner": "^2.0",
        "nicolab/php-ftp-client": "^1.5"
    },

 

原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/181473.html

(0)
上一篇 2021年11月1日
下一篇 2021年11月1日

相关推荐

发表回复

登录后才能评论