• composer update install require 三个命令的的别


    1.当前项目没有vendor目录、 composer.json和ccomposer.lock文件

    • composer update
    S D:phpstudy_proWWWaa> composer update
    Composer could not find a composer.json file in D:phpstudy_proWWWaa
    To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
    
    
    

    没有任何执行结果

    • composer require 
    PS D:phpstudy_proWWWaa> composer require
    Search for a package

     

     生成composer.json文件,目前没有下载依赖包,接下来通过Search for package安装monolog/monolog

    PS D:phpstudy_proWWWaa> composer require
    Search for a package: monolog/monolog                //输入要安装的依赖包
    Enter the version constraint to require (or leave blank to use the latest version): 1.1.*                    //输入版本号
    Search for a package:
    ./composer.json has been created
    Running composer update monolog/monolog
    Loading composer repositories with package information
    Updating dependencies
    Lock file operations: 1 install, 0 updates, 0 removals
      - Locking monolog/monolog (1.1.0)
    Writing lock file
    Installing dependencies from lock file (including require-dev)
    Package operations: 1 install, 0 updates, 0 removals
      - Installing monolog/monolog (1.1.0): Extracting archive
    1 package suggestions were added by new dependencies, use `composer suggest` to see details.
    Generating autoload files
    PS D:phpstudy_proWWWaa>
    

      

    项目根目录生成了vendor目录,composer.json和ccomposer.lock文件

    • composer install
    PS D:phpstudy_proWWWaa> composer install
    Composer could not find a composer.json file in D:phpstudy_proWWWaa
    To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
    PS D:phpstudy_proWWWaa>

    没有composer.json无法安装

    2.只有composer.json的情况

    • composer update
    PS D:phpstudy_proWWWaa> composer update
    

     新生成vendor和composer.lock

    • composer reqiuire
    PS D:phpstudy_proWWWaa> composer require
    Search for a package:  // 这里直接回车不安装任何依赖
    

     新生成 vendor、composer.lock

    • composer install
    PS D:phpstudy_proWWWaa> composer install
    

     提示composer.lock缺失,原因是install命令是根据composer.lock文件安装依赖包, 所以建议使用composer update命令,但是这个命令仍然生成了vendor composer.lock文件。

       

      

  • 相关阅读:
    [apue] FIFO:不是文件的文件
    [apue] 等待子进程的那些事儿
    [apue] popen/pclose 疑点解惑
    [apue] 使用 popen/pclose 的一点疑问
    [apue] 使用 poll 检测管道断开
    [apue] dup2的正确打开方式
    [apue] 管道原子写入量的一个疑问
    [apue] 测试管道容量的一些疑问
    【新阁教育】再也不用担心我的PLC通信不上了
    【新阁教育】三菱PLC的这个功能,真的很强大
  • 原文地址:https://www.cnblogs.com/xiangdongsheng/p/14320630.html
Copyright © 2020-2023  润新知