天天看點

about composer

作者:瘋狂大開發
about composer

composer簡介

composer是一款PHP依賴管理工具,類似于node.js的npm,java的maven,gradle等等。如果在一個PHP項目中一些庫依賴于其他庫,就聲明所依賴的庫,Composer 就會找出相應版本的包并安裝,預設情況下下載下傳到項目的某個目錄中(例如 vendor)進行安裝。使用 Composer 可以很輕松的使用一個指令将其他人的優秀代碼引用到我們的項目中來。

windows系統怎麼安裝composer

打開 https://getcomposer.org/download/ ,下載下傳composer-setup,點選“下一步”,過程中會要選擇PHP路徑,選到php.exe即可。

直接敲入 composer,檢查是否安裝成功

about composer

熟悉了上面的英文,也就熟悉了composer應用場景中90%,一起來看看

______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.5.5 2023-03-21 11:50:05

Usage:
// 指令 選項 參數
  command [options] [arguments]
// 選項
Options:
---help 幫助資訊
  -h, --help                     Display help for the given command. When no command is given display help for the list command
---quiet 安靜模式 不輸出任何資訊
  -q, --quiet                    Do not output any message
---version 顯示目前版本
  -V, --version                  Display this application version
---ansi 強制 ansi輸出
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
---no interation 不要問任何互動問題
  -n, --no-interaction           Do not ask any interactive question
---profile 展示計時和記憶體使用資訊
      --profile                  Display timing and memory usage informatio
---no plugins 禁用插件      
      --no-plugins               Whether to disable plugins.
---跳過composer.json裡所有腳本執行
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
---working-dir 使用指定的工作目錄
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
---no cache 禁用緩存
      --no-cache                 Prevent use of the cache
---verbose 增加資訊曝光  vvv表示debug
  -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 顯示composer簡短介紹
  about                Shows a short information about Composer
--archive 建立composer包的歸檔
  archive              Creates an archive of this composer package
--audit 檢查已安裝包的安全建議
  audit                Checks for security vulnerability advisories for installed packages
--browse 在浏覽器打開包的倉庫位址或者首頁  
  browse               [home] Opens the package's repository URL or homepage in your browser
--bump 提升composer.json最低要求版本為已安裝版本
  bump                 Increases the lower limit of your composer.json requirements to the currently installed versions
--check-platform-reqs 檢查平台要求是否已滿足
  check-platform-reqs  Check that platform requirements are satisfied
--clear cache 清理緩存  
  clear-cache          [clearcache|cc] Clears composer's internal package cache
--completion 轉儲腳本
  completion           Dump the shell completion script
--config 設定配置選項
  config               Sets config options
--create-project 建立項目
  create-project       Creates new project from a package into given directory
--depends 展示哪項依賴決定的目前包安裝
  depends              [why] Shows which packages cause the given package to be installed
--diagnose 診斷系統,識别常見錯誤
  diagnose             Diagnoses the system to identify common errors
--dump autoload 轉儲自動加載
  dump-autoload        [dumpautoload] Dumps the autoloader
--exec 執行供應的二進制編碼  
  exec                 Executes a vendored binary/script
--fund 如何自助依賴?  
  fund                 Discover how to help fund the maintenance of your dependencies
--global 允許全局運作指令
  global               Allows running commands in the global composer dir ($COMPOSER_HOME)
--help 展示指令的幫助
  help                 Display help for a command
--init 目前目錄建立composer.json檔案  
  init                 Creates a basic composer.json file in current directory
--install 從composer.lock安裝項目,沒有composer.lock就以composer.json為準
  install              [i] Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json
--licenses 展示依賴的licenses資訊
  licenses             Shows information about licenses of dependencies
--list列舉指令
  list                 List commands
--outdated 展示可以更新的依賴包,以及最新的版本号  
  outdated             Shows a list of installed packages that have updates available, including their latest version
--prohibits 沖突展示,展示哪些已安裝的依賴包阻止特定依賴包
  prohibits            [why-not] Shows which packages prevent the given package from being installed
--reinstall 解除安裝、重裝指定的依賴包
  reinstall            Uninstalls and reinstalls the given package names
--remove 從require或者require-dev移除包
  remove               Removes a package from the require or require-dev
--require 添加依賴包到composer.json配置檔案,并且安裝依賴包
  require              [r] Adds required packages to your composer.json and installs them
--run script 運作composer.json裡的腳本  
  run-script           [run] Runs the scripts defined in composer.json
--search 查找依賴包
  search               Searches for packages
--selfupdate 更新composer.phar到最新版本
  self-update          [selfupdate] Updates composer.phar to the latest version
--show 展示依賴包的資訊
  show                 [info] Shows information about packages
--status 展示本地修改的依賴包的清單
  status               Shows a list of locally modified packages
--suggests 展示依賴包的建議
  suggests             Shows package suggestions
--update 參照composer.json配置更新依賴包到最新版,并且更新composer.json檔案
  update               [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file
--validate 驗證composer.json和composer.lock檔案
  validate             Validates a composer.json and composer.lock           

繼續閱讀