使用TP5.0框架的驗證碼時需要先安裝驗證碼類,但是在安裝中遇到了各種各樣的問題,搞了半天終於安裝成功了,下面將問題匯總一下,
首先要安裝composer,大部分“composer require topthink/think-captcha
”命令無法運行或者提示不是內部文件或可執行命令,都是因為沒有安裝composer,或安裝不成功。直接百度搜composer即可,有鏈接,百度經驗里也有教程,不在這里詳細介紹了。
composer安裝成功后,在你的項目主目錄地址欄里輸入cmd,然后輸入composer require topthink/think-captcha
來下載安裝captcha,當然此時有很大概率會報錯,
來說一下我遇到的兩個問題吧,
第一:網絡問題,輸入“”composer require topthink/think-captcha
“”窗口一直無響應,此時需要使用以下命令修改composer配置文件,使用國內鏡像。原因你懂的。
composer config -g repo.packagist composer https://packagist.phpcomposer.com
第二:版本問題:此時有大概率會引版本不符而報錯,錯誤提示代碼如下:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- topthink/think-captcha v2.0.1 requires topthink/framework 5.1.x-dev -> satisfiable by topthink/framework[5.1.x-dev] but these conflict with your requirements or minimum-stability.
- topthink/think-captcha v2.0 requires topthink/framework 5.1.x-dev -> satisfiable by topthink/framework[5.1.x-dev] but these conflict with your requirements or minimum-stability.
- Installation request for topthink/think-captcha ^2.0 -> satisfiable by topthink/think-captcha[v2.0, v2.0.1, v2.0.2].
- Conclusion: don't install topthink/framework v5.1.35
- Conclusion: don't install topthink/framework v5.1.34
- Conclusion: don't install topthink/framework v5.1.33
- Conclusion: don't install topthink/framework v5.1.32
- Conclusion: don't install topthink/framework v5.1.31
- Conclusion: don't install topthink/framework v5.1.30
- Conclusion: don't install topthink/framework v5.1.29
- Conclusion: don't install topthink/framework v5.1.28
- Conclusion: don't install topthink/framework v5.1.27
- Conclusion: don't install topthink/framework v5.1.26
- Conclusion: don't install topthink/framework v5.1.25
- Conclusion: don't install topthink/framework v5.1.24
- Conclusion: don't install topthink/framework v5.1.23
- Conclusion: don't install topthink/framework v5.1.22
- Conclusion: don't install topthink/framework v5.1.21
- Conclusion: don't install topthink/framework v5.1.20
- Conclusion: don't install topthink/framework v5.1.19
- Conclusion: don't install topthink/framework v5.1.18
- Conclusion: don't install topthink/framework v5.1.17
- Conclusion: don't install topthink/framework v5.1.16
- Conclusion: don't install topthink/framework v5.1.15
- Conclusion: don't install topthink/framework v5.1.14
- Conclusion: don't install topthink/framework v5.1.13
- Conclusion: don't install topthink/framework v5.1.12
- Conclusion: don't install topthink/framework v5.1.11
- Conclusion: don't install topthink/framework v5.1.10
- Conclusion: don't install topthink/framework v5.1.9
- Conclusion: don't install topthink/framework v5.1.8
- Conclusion: don't install topthink/framework v5.1.7
- Conclusion: don't install topthink/framework v5.1.6
- Conclusion: don't install topthink/framework v5.1.5
- Conclusion: don't install topthink/framework v5.1.4
- Conclusion: don't install topthink/framework v5.1.3
- Conclusion: don't install topthink/framework v5.1.2
- Can only install one of: topthink/framework[v5.1.0, v5.0.3].
- Can only install one of: topthink/framework[v5.1.0, v5.0.3].
- topthink/think-captcha v2.0.2 requires topthink/framework 5.1.* -> satisfiable by topthink/framework[v5.1.0, v5.1.1, v5.1.10, v5.1.11, v5.1.12, v5.1.13, v5.1.14, v5.1.15, v5.1.16, v5.1.17, v5.1.18, v5.1.19, v5.1.2, v5.1.20, v5.1.21, v5.1.22, v5.1.23, v5.1.24, v5.1.25, v5.1.26, v5.1.27, v5.1.28, v5.1.29, v5.1.3, v5.1.30, v5.1.31, v5.1.32, v5.1.33, v5.1.34, v5.1.35, v5.1.4, v5.1.5, v5.1.6, v5.1.7, v5.1.8, v5.1.9].
- Conclusion: don't install topthink/framework v5.1.1
- Installation request for topthink/framework (locked at v5.0.3, required as ^5.0) -> satisfiable by topthink/framework[v5.0.3].
Installation failed, reverting ./composer.json to its original content.
此時我們需要同步一下各自版本,建議使用命令:composer update --ignore-platform-reqs
執行成功之后,就可以使用命令:composer require topthink/think-captcha
來安裝驗證碼類了