composer-创建自己的依赖库

news/2025/3/6 3:03:00/

1.环境

  • 码云账号(或者GitHub)码云地址
  • composer 官方仓库账号 Packagist composer官方仓库
  • 安装composer

2.步骤

2.1 发行composer的依赖包是需要从git 或者svn里拉取的,所以得先在码云里创建一个仓库

在这里插入图片描述

2.2 依赖包中必须有composer.json配置标明名字依赖等信息,配置大概如下,配置完后提交到码云仓库中

{"name": "angryshan/lss","type": "library","description": "angryshan lss","keywords" : ["angryshan", "lss"],"authors": [{"name": "angryshan","email": "angryshan@qq.com"}],"require": {"php": ">=7.4.0","ext-pdo": "*"},"autoload": {"psr-4": {"angryshan\\lss\\": "src/"}}
}

注意:name 必须包含’/'符号,并且这个名字在composer require 下来后会自动生成对应名字的文件夹,这里的require 后文件夹是 vendor/angryshan/lss

在这里插入图片描述

2.3 提交到git完成后,创建一个发行版本

在这里插入图片描述

2.4 完成后登录https://packagist.org ,点击右上角submit按钮,填写git地址,然后点击check

在这里插入图片描述

2.5 成功
在这里插入图片描述
2.6 项目运用

composer require angryshan/lss dev-master

3.composer require报错

一、Could not find package angryshan/lss. It was however found via repository search, which indicates a consistency issue with the repository.

解决办法:先切换一下composer镜像

#查看源配置
composer config -g -l
#切换为阿里云源
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
#切换会原来的源
composer config -g repo.packagist composer https://repo.packagist.org

http://www.ppmy.cn/news/263198.html

相关文章

nestjs超详细从零到零点五详细入门项目搭建过程

nestjs超详细从零到零点五详细入门项目搭建过程 项目完整地址github,修复了一些swagger文档接口,传参显示问题 从零到有搭建一个完整的后台管理系统项目 涉及到的知识 controller控制器provider提供者module模块middleware中间件filter过滤器pipe管道…

idea报错:Unable to connect to localhost_6379] with root cause

问题描述 启动瑞吉外卖项目后,在测试采用Redis的功能时报错(页面状态码为500,是服务器端出错): Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing f…

【云原生|Kubernetes】08-Pod中的Init容器

【云原生Kubernetes】08-Pod中的Init容器 文章目录 【云原生Kubernetes】08-Pod中的Init容器简介理解 Init 容器Init容器使用场景创建包含Init容器的Pod具体行为资源Pod 重启的原因 调试Init容器理解 Pod 的状态 简介 Init 容器是一种特殊容器,在 Pod内的应用容器启…

ubuntu虚拟机 立即使用客户机 灰色

环境 Ubuntu16.04 VMware 16.2.2 Windows 10 错误 the system is running in low graphic CtrlALTF1 进入控制台输入用户名和密码进入系统cd /etc/X11sudo cp xorg.conf.failsafe xorg.conf重启 分辨率低、无法适应客户机器 sudo apt-get updatesudo apt-get upgrade 界面卡…

使用命令启动IOS模拟器

通过命令行操作iOS模拟器 列出已安装的所有可用的模拟器设备 xcrun instruments -s的MacBook Pro [88D67194-8AC9-5CED-993C-EDAEDC2A3395] Apple TV (12.2) [BAA9D4FF-47F3-4474-AFA1-BB01C1723827] (Simulator) Apple TV 4K (12.2) [478802EF-59F9-4394-A429-A0B2151F90A7]…

mmc二维下料例子

给定如下数据: 最大长度 12560; 最大宽度 1500; 需要长度 {12560, 7890, 8845, 8990, 4890, 7540, 3990, 4890, 5230}; 需要宽度 {210, 325, 410, 646, 180, 284, 232, 575, 760}; 需要数量 {55, 43, 88, 46, 123, 56, 180, 28, 36}; 如何切割,面积…

js将String字符串当作HTML来处理,显示在页面上

接收到string类型的消息&#xff0c;需要转为html&#xff0c;并显示到页面上。 实现如下&#xff1a; 接收到的参数举例&#xff1a; const data {html: "<h1 style\"text-align: center;\">213</h1><p><span style\"color: rgb(20…

[Yarn] info There appears to be trouble with your network connection. Retrying...

yarn install命令时报错&#xff0c;原因是到了timeout时间&#xff0c;没有安装完某个包&#xff0c;一是有可能网络确实太慢&#xff0c;二是可能你的包太大了&#xff0c;安装时间只要超过timeout时间就会说你网络有问题。 解决方法&#xff1a; 1、如果是网络的问题的话&am…