


CRM is a command line tool I made a long time ago to manage composer sources. It is designed to use simple commands to manage multiple sources. China mirror switching, so as to manage them conveniently;
At that time, I didn’t know much about the composer plug-in, so the method was relatively rough. The bottom layer was to execute the composer command to achieve the purpose of switching sources, and it was used on Linux Fortunately, there is almost no special perception, but the win will be a bit sluggish. This is also obvious, after all, when switching, it is equivalent to executing multiple commands at the same time; later, due to the opportunity of work, I learned about the development of the composer plug-in, so the idea of refactoring came up;
with 1.x Compared with the version, 2.x mainly has the following changes:
Metadata storage location changes
In the 1.x version, it is under the user's Home folder A customized file, all user operations are ultimately persisted to this json file; the new version stores metadata in config.json under the composer global path:
{ "config": { "_alias": { "val": "validate", "up": "update", "req-sf": "require symfony/event-dispatcher symfony/console", "req": "require", "i": "install" }, "_repositories": [{ "name": "composer", "url": "https://packagist.org", "homepage": "", "author": "" }, { "name": "phpcomposer", "url": "https://packagist.phpcomposer.com", "homepage": "", "author": "" }, { "name": "composer-proxy", "url": "https://packagist.composer-proxy.org", "homepage": "", "author": "" }, { "name": "laravel-china", "url": "https://packagist.laravel-china.org", "homepage": "", "author": "" }] }, "repositories": { "packagist": { "type": "composer", "url": "https://packagist.laravel-china.org" } } }
This is maintained by composer We borrowed a file and occupied a field in it. This is also more in line with the composer ecosystem
Command changes
1.x version is an independent entry application, and the commands all start with the crm keyword, such as crm ls; in the new version In the plug-in, crm becomes a command provider role, so in the new version we use the composer entry;
New version usage
List all available images
$ composer repo:ls composer https://packagist.org phpcomposer https://packagist.phpcomposer.com * composer-proxy https://packagist.composer-proxy.org laravel-china https://packagist.laravel-china.org
The mark "*" indicates the source currently in use;
Switch mirror
$ composer repo:use Please select your favorite registry (defaults to composer) [0] composer [1] phpcomposer [2] composer-proxy [3] laravel-china >
You can also directly append the mirror name to skip selecting
$ composer repo:use phpcomposer
Add option- -current/-c switches the source for the current project. The default is to modify the global source.
All commands
Execute the following command to view
$ composer repo
Summary
In addition to the changes in usage, the most significant improvement in the new version may be the speed improvement; such as If you have any questions, you are welcome to give feedback. You can leave a message under the post or post to github issues.
I hope this small tool will bring convenience to everyone in their work and development.
For more programming related content, please pay attention to the Programming Introduction column on the php Chinese website!
The above is the detailed content of How to refactor the Composer source management tool CRM into a composer plug-in. For more information, please follow other related articles on the PHP Chinese website!

本文由composer教程栏目给大家介绍关于在Debian11上是怎么一步步安装,以及使用Composer的 ,非常详细哦~希望对需要的朋友有所帮助!

Composer是PHP的依赖管理工具,它允许开发者将第三方库和框架与自己的项目进行集成。它的主要功能包括:1、依赖管理;2、版本控制;3、自动加载;4、扩展开发;5、集成其他工具。它简化了PHP项目的依赖管理过程,确保项目的稳定性和可维护性。通过使用Composer,开发者可以更加高效地管理自己的项目和集成第三方库和框架。

composer修改php路径的方法:1、搜索“composer.bat”并复制到项目文件夹;2、编辑“composer.bat”,将内容修改为“@ECHO OFF php "%~dp0composer.phar" %*”即可。

在PHP开发中,我们经常要处理各种依赖包,这些依赖包可能是其他开发者编写的PHP库文件,也可能是一些第三方工具和框架。为了方便管理这些依赖包,我们可以使用Composer来进行相关的安装和管理工作。Composer是一个开源的PHP依赖管理工具,它可以帮助我们自动化安装、更新和卸载PHP依赖包。通过Composer,我们可以轻松地管理我们应用中的不同依赖,同

随着PHP的日益流行,PHP开发人员面临着许多挑战,其中包括代码管理、可重用性和依赖性管理。这些问题可以使用包管理器来解决,而Composer是PHP最受欢迎的包管理器之一。在本文中,我们将探讨使用Composer和PHP包管理器的最佳实践,从而提高您的PHP开发效率和代码质量。何为Composer?Composer是一款PHP包管理器,它可以轻松管理PHP

Composer是一个PHP的依赖管理工具,可以帮助开发者有效地管理项目中的依赖关系。通过Composer,我们可以轻松地引入第三方库、框架以及其他项目所需的各种资源。创建一个Composer项目非常简单,只需按照以下步骤进行操作:首先需要确保在本地已经安装了Composer。可以在终端中运行composer-v命令来确认是否已经安装成功。在项目的根目录中

Composer是一个PHP的依赖管理工具,它可以帮助开发者在PHP项目中管理和安装依赖的库文件。Composer通过一个中央化的存储库来管理所有的依赖库文件,这个存储库包含了各种可用的依赖库的信息和版本信息。开发人员可以在项目中使用Composer来声明所需的依赖库,然后Composer会自动从存储库中获取并安装这些依赖库的最新版本到项目中的某个目录中。

随着现代Web开发技术的迅速发展,依赖管理成为了一个越来越重要的议题。无论是前端还是后端开发,我们需要引入各种各样的库和框架来达到更高的开发效率和更好的应用性能。而这些库和框架的组织、版本控制和安装管理问题则成为了一个值得思考和解决的难题。Composer就是为了解决PHP应用开发中依赖管理问题而推出的一个开源工具。它的作用类似于Node.js


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Linux new version
SublimeText3 Linux latest version

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!
