Blogger Information
Blog 33
fans 0
comment 0
visits 17248
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
composer 常用命令
lucaslwk
Original
735 people have browsed it

composer 常用命令

1.查看版本号

  1. composer -V

2.更新

  1. composer self-update

3.切换阿里源

  1. composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

4.创建或更新 composer 的自动加载器

  1. composer dumpautoload

5.自定义类的自动加载

  1. {
  2. "autoload": {
  3. "classmap": ["lib/", "src/", "app/Test1.php"]
  4. }
  5. }

6.自定义其他非类文件的自动加载

  1. {
  2. "autoload": {
  3. "files": ["config/database.php", "func/helper.php"]
  4. }
  5. }

7.PSR-4 类命名空间映射到类文件所在的路径,类名与类文件同名,且文件中只有一个类

文件结构

  1. acme-log-writer
  2. lib
  3. File_Writer.php

composer.json

  1. {
  2. "psr-4": {
  3. "Acme\\Log\\Writer\\": ["acme-log-writer/lib/"]
  4. }
  5. }

File_Writer.php

  1. namespace Acme\Log\Writer;
  2. class File_Writer
  3. {
  4. public static function show()
  5. {
  6. return '当前类名:' . __CLASS__;
  7. }
  8. }
  1. echo \Acme\Log\Writer\File_Writer::show() . '<br>';

8.第三方组件库/包下载

  1. 平台:https://packagist.org/

下载方式

  1. 1.终端运行 composer require youngyezi/captcha
  2. 2.json内手工添加
  3. "require": {
  4. "youngyezi/captcha": "6.0.*"
  5. }
  6. 终端运行composer install安装

9.其他常用的指令

  1. - 更新所有包或指定的包: `composer update 空/*/包名列表空格分隔`
  2. - 移除包: `composer remove 包`
  3. - 查看所有包: `composer show`
  4. - 查看指令帮助信息: `composer help install`
  5. - 更多指令: `composer`回车后可以看到
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post