Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to ReFactor Composer Source Management tool CRM to composer plug-in

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to reconstruct the Composer source management tool CRM for the composer plug-in, the article introduces in great detail, has a certain reference value, interested friends must read it!

CRM is a command-line tool I made a long time ago to manage composer sources, which is designed to easily manage multiple Chinese images by switching between them with simple commands.

At that time, I didn't know much about the composer plug-in, so the practice was relatively rough. The bottom layer achieved the purpose of switching the source by executing the composer command. Fortunately, there was almost no special perception for using it on linux, but it would be a little slow on win. This is also obvious, after all, switching is equivalent to executing multiple commands at the same time; later, due to the opportunity to learn about the development of the composer plug-in, I came up with the idea of refactoring.

Compared with 1.x, 2.x has the following major changes:

Change of metadata storage location

In version 1.x, a file is customized under the user's Home folder, and all user operations are eventually persisted to this json file. In the new version, metadata is stored in config.json under the global path of composer:

{"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 a file maintained by composer. We borrowed it and occupied a field in it. This is also more in line with the composer ecology.

Change of command

Version 1.x is a stand-alone portal application, and commands start with crm keywords, such as crm ls; in the new plug-in, crm becomes a command provider role, so we use the composer entry in the new version

New version of usage

List all available mirrors

$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 label "*" indicates the source currently in use

Switch mirrors

$composer repo:usePlease select your favorite registry (defaults to composer) [0] composer [1] phpcomposer [2] composer-proxy [3] laravel-china >

You can also directly append the image name to skip the selection.

$composer repo:use phpcomposer

Add option-current/-c is the current project switch source, and the default is to modify the global source.

All commands

Execute the following command to view

The above $composer repo is all the content of the article "how to ReFactor the Composer Source Management tool CRM into the composer plug-in". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report