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

Installation and use of Composer

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly explains "how to install and use Composer". Friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and use Composer.

Install php-r "copy ('https://getcomposer.org/installer',' composer-setup.php');" php-r "if (hash_file ('SHA384',' composer-setup.php') = = 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') {echo' Installer verified';} else {echo 'Installer corrupt'; unlink (' composer-setup.php');} echo PHP_EOL;" php composer-setup.phpphp-r "unlink ('composer-setup.php');"

The above code comes from the official website.

Partial installation

After the above code execution is completed, it is only downloaded to the composer.phar file and can be executed anywhere through php composer.phar.

Global installation

Global installation is just to install composer.phar under PATH. You can do something like this:

Sudo mv composer.phar / usr/local/bin/composer domestic image acceleration

Use full Chinese mirrors provided by Composer Chinese network to accelerate.

Single project acceleration

Enter the project directory (that is, the directory where the composer.json file is located) and execute:

Composer config repo.packagist composer https://packagist.phpcomposer.com

This command adds the image acceleration configuration at the end of the composer.json file:

"repositories": {"packagist": {"type": "composer", "url": "https://packagist.phpcomposer.com"}} global acceleration

Can be executed directly:

Composer config-global repo.packagist composer https://packagist.phpcomposer.com configuration

Refer to the official configuration documentation.

Because by default, composer generates a .composer folder under the user's home directory to store configuration-related folders, so we can configure these parts.

Composer config-- global data-dir / www/.composercomposer config-- global cache-dir / www/.composer# cache-files-maxsize can also be slightly larger, and the cache time is related to Auth.

Gitlab token can view https://docs.gitlab.com/ee/api/README.html#oauth-2-tokens

Matters needing attention

When type is configured as gitlab, github, etc., authentication information will be selected first through the configuration in the .composer / auth.json file. If the problems related to Auth authentication are not solved, ordinary vcs such as git can be used.

At this point, I believe you have a deeper understanding of "the installation and use of Composer". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

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