Composer offline installation local package method

藏色散人
Release: 2021-05-10 15:31:02
forward
5169 people have browsed it

The following tutorial column ofcomposerwill introduce to you how to install local packages offline with composer. I hope it will be helpful to friends who need it!

The local situation is like this. Composer has been installed because the project (thinkphp) needs to install an ffmpeg package, but it failed to install it many times. Later I found out that it was on git, so I simply installed the package. I downloaded it from git and want to install it locally, but I really can't stand the installation speed. I switched to the domestic source and the Alibaba source, but it just couldn’t be downloaded, so I had to download the package offline and install it locally.

I was very happy to read Baidu’s articles on this, but most methods didn’t work. So I asked a friend to do some skeleton work, and it turns out that only useful information can be found abroad. Let’s get straight to the practical stuff:

First delete composer.lock in the project directory, then transfer the downloaded package to a place that can generate a URL, the kind that can be accessed directly via http, and then edit composer.json

"repositories": [ { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" }, { "type": "package", "package": { "name": "php-ffmpeg/php-ffmpeg", "version": "0.16", "dist": { "url": "http://192.168.100.52/upload/PHP-FFMpeg-0.16.zip", "type": "zip" } } } ]
Copy after login

Then, add php-ffmpeg/php-ffmpeg to require (of course, keep your other require items, this is just to talk about this offline package), as follows:

"require": { "php-ffmpeg/php-ffmpeg": "^0.16.0" }
Copy after login

Then install it, Because my composer has been upgraded to 2.0, I added a --no-plugins parameter to see if there is a yellow warning. If you are 1.0, you don’t need to add this parameter:

composer require php-ffmpeg/php-ffmpeg --no-plugins
Copy after login

or run The following command can also be used:

composer update
Copy after login

What is mentioned above is the entire actual installation process, just follow it.

Finally, in order to facilitate the installation of composer in the future, delete the newly generated composer.lock, edit composer.json, delete the package section, and restore it:

"repositories": [ { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" } ]
Copy after login

Update composer again That's it.

Finally, let’s talk about the reference article:

https://stackoverflow.com/questions/29994088/composer-require-local-package

https://getcomposer. org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

The above is the detailed content of Composer offline installation local package method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
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!