Blogger Information
Blog 14
fans 0
comment 0
visits 12044
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
composer
念旧
Original
663 people have browsed it

composer

1. composer 是什么

  • php 包依赖管理工具
  • 包: 组件,一组相关的类,接口,trait 的结合体
  • 依赖: A -> B -> C -> D
  • composer 就是用 php 语言开发的

2. 组件放在了哪里

3. 从哪下载

4. windows 下载

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

  • php composer.phar -V

  • 简化成: composer -V
  • 将镜像改为国内阿里云:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

5. 常用指令

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

6. 自动加载 autoload

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