Home >Development Tools >composer >Install Composer on Mac and install TP5 with Composer
The following tutorial column of composer will 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!
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)
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/
You only need to do two things to install Composer
1. Download and install composer.phar
2. Configure the Chinese image
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
composer version number and date are consistent with the official website
php composer.phar -v
3. Finally, set it as a global command
mv composer.phar /usr/local/bin/composer
The installation is now complete
4. Next, configure the Chinese image
Global replacement:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
Local configuration: (valid only for the current directory)
composer config repo.packagist composer https://packagist.phpcomposer.com
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" } }
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.*" } }
After executing the above command, it becomes
{ "require": { "monolog/monolog": "1.2.*" }, "repositories": { "packaglist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }
and then execute composer install to install MongoDB
Direct installation does not require creating composer.json, just execute the following command.
composer create-project topthink/think tp5 --prefer-dist
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!