Install Composer on Mac and install TP5 with Composer

藏色散人
Release: 2020-08-21 11:38:44
forward
3092 people have browsed it

The following tutorial column ofcomposerwill introduce to you how to install Composer on Mac and how to install TP5 with Composer. I hope it will be helpful to friends in need!

Install Composer on Mac and install TP5 with Composer

Mac environment installation Composer


Mac version: macOS High Sierra 10.13.4

Git version: 2.17.0

PHP version: 7.0.29 (cli) (built: Apr 12 2018 03:15:13) (NTS)

Introduction


Composer is used by PHP Tools for managing dependency relationships.

You can declare the external tool libraries (libraries) you depend on in your project, and Composer will install these dependent library files for you.

Composer can also manage projects. In general, Composer is a PHP-based version control and project management tool.

English official website: https://getcomposer.org/
English mirror: https://packagist.org
Chinese official website: https://www.phpcomposer.com/
中文Mirror: https://pkg.phpcomposer.com/

Install Composer


You only need to do two things to install Composer

1. Download and install composer.phar
2. Configure the Chinese image

The details are as follows:


1. Global installation, download the latest version of composer.phar from the official website
2. Verification, execute in the file directory

Make sure PHP is available and version b is greater than 5.6

php -v
Copy after login

composer version number and date are consistent with the official website

php composer.phar -v
Copy after login

3. Finally, set it as a global command

mv composer.phar /usr/local/bin/composer
Copy after login

The installation is now complete

4. Next, configure the Chinese image

Global replacement:

composer config -g repo.packagist composer https://packagist.phpcomposer.com
Copy after login

Local configuration: (valid only for the current directory)

composer config repo.packagist composer https://packagist.phpcomposer.com
Copy after login

The above command will automatically add the mirroring configuration information at the end of the composer.json file in the current project (you can also add it manually):

"repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } }
Copy after login

Take MongoDB expansion as an example, in the current directory Add the composer.json file below, the content is as follows

{ "require": { "monolog/monolog": "1.2.*" } }
Copy after login

After executing the above command, it becomes

{ "require": { "monolog/monolog": "1.2.*" }, "repositories": { "packaglist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }
Copy after login

and then execute composer install to install MongoDB

Composer install TP5


Direct installation does not require creating composer.json, just execute the following command.

composer create-project topthink/think tp5 --prefer-dist
Copy after login


The above is the detailed content of Install Composer on Mac and install TP5 with Composer. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.im
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!