Home > Backend Development > PHP Tutorial > PHP about the use of composer

PHP about the use of composer

不言
Release: 2023-03-28 17:00:02
Original
2984 people have browsed it

This article mainly introduces the use of PHP composer, which has certain reference value. Now I share it with everyone. Friends in need can refer to it.

If the PHP command cannot be found, please indicate the environment variables. There is no php in it. Here you need to search for php on the disk and add the environment variable

composer is a dependent library of php. It will be safer and more efficient to download the third type of package here.

In the command line, first enter the root directory of the specified project (download a composer separately for each project).

The download command for windows is

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

linux is:

curl -sS https://getcomposer.org/installer | php
Copy after login

After downloading, there should be one more composer.phar file in the directory, we can

php composer.phar
Copy after login

Call this file. If a row of usage lists appears, then the installation is successful.

Composer works like this:

There are two files, composer.json and composer.lock, in this directory.

Editing composer.json is to change the content of the dependent package, but this file is not downloaded as soon as it is saved. Instead, it is only saved in this file,

Through

php composer.phar install
Copy after login

is to lock the content in json into the composer.lock folder (the updates of file dependencies are all in composer.lock).

is to lock the content to be updated into the lock through hashing.

php composer.phar update
Copy after login

This sentence is to update the dependency package.

But the update here is to update all dependent packages, but if we only want to update a certain package individually,

We can use this command

composer require new/package
Copy after login

If this sentence If it cannot be installed, then change the sentence below

php composer.phar require new/package
Copy after login

is similar to

php composer.phar require qcloudsms/qcloudsms_php
Copy after login

which is to install Tencent’s SMS service

php composer.phar require phpmailer/phpmailer

In order to install PHPmailer

The added packages are all under ventor

The easiest way is to download the third-party library of PHPmailer from composer

Related recommendations:

Detailed explanation of the steps to create a Composer package in PHP

Installation of PHP dependency package Composer

Use Composer to automatically load the php namespace

The above is the detailed content of PHP about the use of composer. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template