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

Example Analysis of Command\ Parameter\ description in composer

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the example analysis of command\ parameter\ description in composer, which is very detailed and has certain reference value. Friends who are interested must read it!

Install curl-sS https://getcomposer.org/installer | php

Or

Php-r "readfile ('https://getcomposer.org/installer');" | php

Global installation

Mv composer.phar / usr/local/bin/composer installation Chinese image composer config-g repo.packagist composer https://packagist.phpcomposer.com ignores version matching

Composer install/update-ignore-platform-reqs

Install the plug-in package?

Composer global require "fxp/composer-asset-plugin:1.2.0" create Project create-project

You can use Composer to create a new project from an existing package. This is equivalent to installing the package's dependencies to its own vendor directory after executing a git clone or svn checkout command.

This command has several common uses:

You can deploy your application quickly.

You can check out any resource pack and develop patches for it.

Multi-person development projects can be used to speed up the initialization of applications.

To create new projects based on Composer, you can use the "create-project" command. Pass a package name, which will create a directory for your project. You can also specify the version number in the third parameter, otherwise you will get the latest version.

If the directory does not currently exist, it is automatically created during installation.

Php composer.phar create-project doctrine/orm path 2.2.*

In addition, you can start the project from an existing composer.json file instead of using this command.

By default, this command looks for the package you specified on packagist.org.

Create Project-Parameter

-- repository-url: provides a custom repository to search for packages, which will be used instead of packagist.org. It can be a HTTP URL pointing to a composer repository, or a local path to a packages.json file.

-- stability (- s): the minimum stable version of the resource bundle. Default is stable.

-- prefer-source: install from source when packages are available.

-- prefer-dist: install from dist when packages are available.

-- dev: install the package listed in the require-dev field.

-- no-install: disable installation of package dependencies.

-- no-plugins: disable plugins.

-- no-scripts: disables script execution defined in the root resource bundle.

-- no-progress: removes progress information, which avoids cluttered display of terminals or scripts that do not handle line breaks.

-- keep-vcs: skip the missing VCS when creating. This is very useful if you run the create command in non-interactive mode.

Self-updating self-update

To upgrade Composer itself to the latest version, simply run the self-update command. It will replace your composer.phar file to the latest version.

Php composer.phar self-update

If you want to upgrade to a specific version, you can simply specify it like this:

Php composer.phar self-update 1.0.0-alpha7

If you have installed Composer for the entire system (see Global installation), you may need to run it under root permissions:

Sudo composer self-update self-update-parameters

-- rollback (- r): roll back to the last version you have installed.

-- clean-backups: deletes the old backup during the update process, which makes the updated current version the only backup available.

Search search

The search command allows you to search for dependent packages for the current project, usually it only searches packages on packagist.org, and you can simply enter your search criteria.

Php composer.phar search monolog

You can also do a multi-conditional search by passing multiple parameters.

Search-Parameter

-- only-name (- N): search only for the specified name (exact match).

Declare dependence on require

The require command adds a new dependency package to the composer.json file in the current directory.

Php composer.phar require

When you add or change dependencies, the modified dependencies are installed or updated.

If you do not want to specify the dependency package interactively, you can specify the dependency package directly in this order.

Php composer.phar require vendor/package:2.* vendor/package2:dev-master declares dependency-parameters

-- prefer-source: install from source when packages are available.

-- prefer-dist: install from dist when packages are available.

-- dev: install the package listed in the require-dev field.

-- no-update: disables automatic updates of dependencies.

-- no-progress: removes progress information, which avoids cluttered display of terminals or scripts that do not handle line breaks.

-- update-with-dependencies also updates the dependencies of the new package.

Update update

To get the latest version of the dependency and to upgrade the composer.lock file, you should use the update command.

Php composer.phar update

This will resolve all dependencies of the project and write the exact version number to composer.lock.

If you just want to update a few packages, you can list them separately like this:

Php composer.phar update vendor/package vendor/package2

You can also use wildcards for batch updates:

Php composer.phar update vendor/* updates-Parameter

-- prefer-source: install from source when packages are available.

-- prefer-dist: install from dist when packages are available.

-- dry-run: simulates commands without actually doing anything.

-- dev: installs the package listed in the require-dev field (this is a default).

-- no-dev: skip the packages listed in the require-dev field.

-- no-scripts: skip the scripts defined in the composer.json file.

-- no-plugins: close plugins.

-- no-progress: removes progress information, which avoids cluttered display of terminals or scripts that do not handle line breaks.

-- optimize-autoloader (- o): convert PSR-0/4 autoloading to classmap for faster loading support. This is recommended especially in a production environment, but because it takes some time to run, it is not used as the default.

-- lock: updates only the hash of the lock file, canceling the warning about the obsolescence of the lock file.

-- with-dependencies also updates the dependencies of packages in the whitelist, which will be updated recursively.

Install install

The install command reads the composer.json file from the current directory, handles the dependencies, and installs it into the vendor directory.

Php composer.phar install

If a composer.lock file exists in the current directory, it reads the dependent version from this file instead of getting the dependency based on the composer.json file. This ensures that every user of the library gets the same dependent version.

If there is no composer.lock file, composer will create it after processing the dependency.

Installation-Parameter

-- prefer-source: there are two ways to download packages: source and dist. The dist method will be used by default for stable versions of composer. Source represents the version control source. If-- prefer-source is enabled, composer will be installed from source, if any. This is very useful if you want to use a bugfix to your project. And dependencies can be obtained directly from the local version library.

-- prefer-dist: in contrast to-- prefer-source, composer will get as much from dist as possible, which will greatly speed up the installation on build servers. This is also a way to avoid the git problem if you don't know how to set it up correctly.

-- dry-run: if you just want to demonstrate rather than actually install a package, you can run the-- dry-run command, which will simulate the installation and show what will happen.

-- dev: installs the package listed in the require-dev field (this is a default).

-- no-dev: skip the packages listed in the require-dev field.

-- no-scripts: skip the scripts defined in the composer.json file.

-- no-plugins: close plugins.

-- no-progress: removes progress information, which avoids cluttered display of terminals or scripts that do not handle line breaks.

-- optimize-autoloader (- o): convert PSR-0/4 autoloading to classmap for faster loading support. This is recommended especially in a production environment, but because it takes some time to run, it is not used as the default.

The above is all the contents of the article "sample Analysis of commands\ parameters\ description in composer". 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