我正在尝试为特定目的创建一个小代理。 我选择使用以下项目:https://github.com/jenssegers/php-proxy
尝试使用composer安装时出现以下错误:
~# > php composer require jenssegers/proxy
Using version ^2.2 for jenssegers/proxy
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install jenssegers/proxy v2.2.1
- Conclusion: remove symfony/http-foundation v4.0.8
- Installation request for jenssegers/proxy ^2.2 -> satisfiable by jenssegers/proxy[v2.2.0, v2.2.1].
- Conclusion: don't install symfony/http-foundation v4.0.8
- jenssegers/proxy v2.2.0 requires symfony/http-foundation ~2.6 -> satisfiable by symfony/http-foundation[v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v2.6.9, v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.25, v2.7.26, v2.7.27, v2.7.28, v2.7.29, v2.7.3, v2.7.30, v2.7.31, v2.7.32, v2.7.33, v2.7.34, v2.7.35, v2.7.36, v2.7.37, v2.7.38, v2.7.39, v2.7.4, v2.7.40, v2.7.41, v2.7.42, v2.7.43, v2.7.44, v2.7.45, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.18, v2.8.19, v2.8.2, v2.8.20, v2.8.21, v2.8.22, v2.8.23, v2.8.24, v2.8.25, v2.8.26, v2.8.27, v2.8.28, v2.8.29, v2.8.3, v2.8.30, v2.8.31, v2.8.32, v2.8.33, v2.8.34, v2.8.35, v2.8.36, v2.8.37, v2.8.38, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
- Can only install one of: symfony/http-foundation[v2.6.0, v4.0.8].
[...]
- Can only install one of: symfony/http-foundation[v2.8.9, v4.0.8].
- Installation request for symfony/http-foundation (locked at v4.0.8) -> satisfiable by symfony/http-foundation[v4.0.8].
Installation failed, reverting ./composer.json to its original content.
我的问题是,我有http-foundation v4.0.8:
~# > php composer show symfony/http-foundation
name : symfony/http-foundation
descrip. : Symfony HttpFoundation Component
keywords :
versions : * v4.0.8
type : library
license : MIT License (MIT) (OSI approved) https://spdx.org/licenses/MIT.html#licenseText
source : [git] https://github.com/symfony/http-foundation.git d0864a82e5891ab61d31eecbaa48bed5a09b8e6c
dist : [zip] https://api.github.com/repos/symfony/http-foundation/zipball/d0864a82e5891ab61d31eecbaa48bed5a09b8e6c d0864a82e5891ab61d31eecbaa48bed5a09b8e6c
names : symfony/http-foundation
autoload
psr-4
Symfony\Component\HttpFoundation\ => .
exclude-from-classmap
requires
php ^7.1.3
symfony/polyfill-mbstring ~1.1
requires (dev)
symfony/expression-language ~3.4|~4.0
Composer是否有理由不安装我的包裹?
由于
答案 0 :(得分:3)
在这种错误中,我总是寻找requires
字。在你的情况下:
jenssegers/proxy v2.2.0 requires symfony/http-foundation ~2.6
这意味着你需要先symfony/http-foundation ~2.6
来满足这个条件。
同样locked at v4.0.8
表示composer.lock
已锁定此值。
composer.lock
composer remove symfony/http-foundation
composer require jenssegers/proxy
requires
关键字当我查看Github(https://github.com/jenssegers/php-proxy)上的包时,我发现它已经发布超过2年了。最后一个版本是v3.0.0-beta2 in October 2017。
就个人而言,我宁愿使用这个软件包,使用Symfony 4支持发布自己的版本,或者联系维护者以获取3.0版稳定版that is Symfony independent。
答案 1 :(得分:1)
不是解决但是解决方法
我使用以下方法在src / Utils / Proxy.php中创建了自己的类:http://php.net/manual/en/book.curl.php#90821
按预期工作(我仍然需要重写所有要自己代理的网页链接)
感谢TomášVotruba的回答