Blogger Information
Blog 41
fans 0
comment 0
visits 30986
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
composer常用指令
陈强
Original
788 people have browsed it

composer 是什么

  • php 包依赖管理工具
  • 包: 组件

从哪下载

windows 下载

  • 官网下载: https://getcomposer.org/composer.phar
  • 将 php.exe 所在路径添加到全局 path 变量中
  • 将下载的 composer.phar 复制到 php.exe 所在目录中
  • 创建 composer.bat:@php "%~dp0composer.phar" %*

常用指令

  • composer install: 安装 composer.josn 中的依赖
  • composer update: 更新依赖
  • composer selfupdate: 更新 composer 版本
  • composer require: 添加依赖到 composer.json 中
  • composer create-project: 安装项目

自动加载 autoload

  • 文件级: “files”, 需要将加载的文件逐个导入
  • 目录级: “classmap”,类目录的映射
  • 空间级: “psr-4”: 命名空间映射到目录
  • 无论是哪一种,最后都要执行一下”composer dump”,更新 composer.json 中的 autoload 配置项

自动加载引入与更新方式

  • PSR-4

Composer 将注册一个 PSR-4 autoloader 到 Acme 命名空间。

  1. {
  2. "autoload": {
  3. "psr-4": {
  4. "Acme\\": "src/"
  5. }
  6. }
  7. }
  • composer dump-autoload

只更新自动加载而不去更新依赖

  1. composer dump-autoload
Correcting teacher:天蓬老师天蓬老师

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