Composer使用内网私有仓库进行包管理
由于长期使用Composer进行包依赖管理,许多公用的类库都会放在GitHub上,在多个项目之间引用依赖,更新版本时,减少了很多成本,但还是存在一些问题:
- 每次更新,本地需要跑过单元你测试,Commit并Push到Github,等待Composer更新后才生效;
- 公司级的模块没有办法放在Github上;
官方方案
庆幸的事,Composer 就提供私有仓库的形式:
{ "repositories": [ { "type": "vcs", "url": "http://svn.example.org/projectA/", "trunk-path": "Trunk", "branches-path": "Branches", "tags-path": "Tags" } ]}
具体参考: https://getcomposer.org/doc/05-repositories.md
由于公司内使用的是 Subverison,使用如上方式导入私有仓库,实际上是通过 svn checkout的形式将指定的 tags检出,这时候 vendor目录下将会出现 .svn目录,导致主项目无法提交,甚至在切换 tags时出现无法检出的情况。
在 Composer项目 issue中有许多人反映此问题,解决方案是通过 svn export来代替 svn checkout,需要使用如下插件:
https://github.com/LinearSoft/composer-svn-export新方案
该插件等于是需要自己搭建一个 packaglist站点,其实仅需要一个 packages.json文件,但是需要有效的 https服务,否则将会出现如下错误:
➜ www.my-project.com composer updateYou are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebugAdded SvnExport repo: NewPackageLoading composer repositories with package information [Composer\Downloader\TransportException] The "https://packagist.my-project.dev/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed Failed to enable crypto failed to open stream: operation failed
如果没有这样的 https服务,可以选择在 gist上建一个 packages.json文件来达到效果:
{ "packages": { "tc/analyse": { "0.9.2": { "name": "tc/analyse", "version": "0.9.2", "source": { "type": "svn", "url": "https://svn.tc.dev/library/analyse", "reference": "/tags/0.9.2" } }, "0.9.3": { "name": "tc/analyse", "version": "0.9.3", "source": { "type": "svn", "url": "https://svn.tc.dev/library/analyse", "reference": "/tags/0.9.3" } }, "dev-master": { "name": "tc/analyse", "version": "dev-master", "source": { "type": "svn", "url": "https://svn.tc.dev/library/analyse", "reference": "/trunk" } } } }}
主项目中 composer.json填充上该 Gist地址
{ "require" : { "php" : ">=5.4.0", "tc/analyse" : "0.9.3", "linearsoft/composer-svn-export" : "^0.1.2" }, "extra" : { "svn-export-repositories" : [ { "name" : "TC", "type" : "composer", "url" : "https://gist.githubusercontent.com/lancerhe/379eeee89fd0db8c0c4ca19c6bddas2f/raw/915a720635949c9d4013746845b952f88af358db" } ] }, "minimum-stability" : "stable"}
运行 composer update
➜ www.my-project.com composer updateYou are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebugAdded SvnExport repo: TCLoading composer repositories with package informationUpdating dependencies (including require-dev) - Updating tapcash/analyse (0.9.2 => 0.9.3) Exporting /tags/0.9.3Writing lock fileGenerating autoload files

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

热门话题

PHP客户端URL(curl)扩展是开发人员的强大工具,可以与远程服务器和REST API无缝交互。通过利用Libcurl(备受尊敬的多协议文件传输库),PHP curl促进了有效的执行

您是否想为客户最紧迫的问题提供实时的即时解决方案? 实时聊天使您可以与客户进行实时对话,并立即解决他们的问题。它允许您为您的自定义提供更快的服务

文章讨论了PHP 5.3中引入的PHP中的晚期静态结合(LSB),从而允许静态方法的运行时分辨率调用以获得更灵活的继承。 LSB的实用应用和潜在的触摸

JWT是一种基于JSON的开放标准,用于在各方之间安全地传输信息,主要用于身份验证和信息交换。1.JWT由Header、Payload和Signature三部分组成。2.JWT的工作原理包括生成JWT、验证JWT和解析Payload三个步骤。3.在PHP中使用JWT进行身份验证时,可以生成和验证JWT,并在高级用法中包含用户角色和权限信息。4.常见错误包括签名验证失败、令牌过期和Payload过大,调试技巧包括使用调试工具和日志记录。5.性能优化和最佳实践包括使用合适的签名算法、合理设置有效期、

使用PHP的cURL库发送JSON数据在PHP开发中,经常需要与外部API进行交互,其中一种常见的方式是使用cURL库发送POST�...
