The following tutorial column from composer will introduce to you how to update the thinkphp version through composer. I hope it will be helpful to friends in need!
Process
Upgrade tp5.1.19 to tp5.1.26.
Enter the project root directory, enter composer update and expect to update to the latest version, but it prompts that nothing has been updated... I tried to clear the cache composer clear-cache, but it still doesn't work. I saw a prompt from the official website that there was a problem with the phpcomposer image recently. I remembered that I had switched to the Chinese image before, so I switched back to the root image
composer config -g repo.packagist composer https://packagist.org
. After clearing the cache, I entered composer update and the update was successful.
Understanding & Explanation
The role of caching: I downloaded a version of a package and downloaded it repeatedly in a short period of time (updating in another project or creating a new project), it will It is much faster because it is fetched from the local cache rather than downloaded from the package repository.
Composer update package default version: Take the topthink/framework package as an example, do not add a specified version number after composer update or composer create-project, download the version seen here, that is, search for topthink from the PHP package warehouse /framework, click to see the version.
tp manual prompts composer to install the latest stable version. If you want to install the latest real-time version, enter
composer create-project topthink/think=5.1.x-dev tp5
. Note that the x here does not ask you to fill in the latest version or the expected version, but 5.1. .x-dev is a version of this package, representing the latest version of 5.1. If you want to download a specific version, you should go to the package repository.
Note: Some package versions have v in front of them, such as v5.1.26, while some packages do not, directly 5.1.26. The details of the package in the package warehouse shall prevail. If there is a v and you forget to enter v, you will be prompted that this version is not available...
composer command
Global switch mirror
composer config -g 镜像
View composer settings
composer config -l
Clear cache
composer clear-cache
Update composer
composer self-update
For more composer-related technical articles, please visit the composer column: https:// www.php.cn/tool/composer/
The above is the detailed content of How to update thinkphp version through composer. For more information, please follow other related articles on the PHP Chinese website!