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

Common commands in Composer

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

Share

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

This article is to share with you about the common commands in Composer. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Composer is a php package management tool, it is very convenient to build projects, load three-party packages, as well as a variety of complex dependencies, automatic loading and other needs.

Install composer

Curl-sS https://getcomposer.org/installer | php--\-- install-dir=/usr/bin\-- filename=composer

After installation, use composer-v to view information such as the version number.

Modify code warehouse source

Since the default source server of composer is abroad, for well-known reasons, download Turtle Speed, we need to replace it with a domestic full source. These two are currently available:

From https://php.cnpkg.org/

Composer config-g repos.packagist composer https://php.cnpkg.org

From Laravel China

Composer config-g repo.packagist composer https://packagist.laravel-china.org

View all global configurations

Composer config-g-- list

View all configurations for a single project

Composer config-list

View a configuration

Composer config-g repositories.packagist.org

Cancel a configuration

Composer config-g-- unset repos.packagist

Create a new project

Create a Yii project

Composer create-project-prefer-dist yiisoft/yii2-app-basic basic.com

The-- prefer-dist after the create-project command can also use-- prefer-source, the difference between them:

-- prefer-dist downloads the .zip package from github and caches it locally. The next installation will be loaded locally, greatly accelerating the installation speed. But she didn't keep the .git folder, no version information. Suitable for development based on this package.

-- prefer-source will clone the source code from github and will not cache it locally (caching can also be used in the latest version). The .git folder is retained so that version control can be achieved. Suitable for modifying source code.

Recommended-- prefer-dist can speed up the speed, and there may be similar warnings when using it:

Failed to download yiisoft/yii2-gii from dist: The zip extension and unzip command are both missing, skipping.Your command-line PHP is using multiple ini files. Run `php-- ini` to show them.

The zip,unzip toolkit is missing in the environment, so install it:

Apt-get install zip unzip

The name of the project package is followed by yiisoft/yii2-app-basic, and the basic.com on the last side specifies the new project folder.

Retrieve the package in the warehouse

Composer search monolog/monolog

Install a new dependency package

Composer require monolog/monolog

Control version number

# specified version composer require monolog/monolog 1.24." version range # valid operators are >, > =, = 1.0 "1.0 meme" 1." equals > = 1.0 "1.2" 1.2.3 "1.2.3"

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