我在laravel中运行composer.json,并且出现以下错误:
fsockopen
我了解由于本地主机和服务器版本不同而发生的情况。在localhost上,其php 7.0和在服务器上,其php 5.6
我的composer.json文件是:
Problem 1
- Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 2
- Installation request for symfony/event-dispatcher v4.0.4 -> satisfiable by symfony/event-dispatcher[v4.0.4].
- symfony/event-dispatcher v4.0.4 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 3
- Installation request for doctrine/instantiator 1.1.0 -> satisfiable by doctrine/instantiator[1.1.0].
- doctrine/instantiator 1.1.0 requires php ^7.1 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 4
- Installation request for phpdocumentor/reflection-docblock 4.3.0 -> satisfiable by phpdocumentor/reflection-docblock[4.3.0].
- phpdocumentor/reflection-docblock 4.3.0 requires php ^7.0 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 5
- Installation request for phpunit/php-token-stream 2.0.2 -> satisfiable by phpunit/php-token-stream[2.0.2].
- phpunit/php-token-stream 2.0.2 requires php ^7.0 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 6
- Installation request for symfony/yaml v4.0.4 -> satisfiable by symfony/yaml[v4.0.4].
- symfony/yaml v4.0.4 requires php ^7.1.3 -> your PHP version (5.6.35) does not satisfy that requirement.
Problem 7
- doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (5.6.35) does not satisfy that requirement.
- laravel/framework v5.4.36 requires doctrine/inflector ~1.1 -> satisfiable by doctrine/inflector[v1.3.0].
- Installation request for laravel/framework v5.4.36 -> satisfiable by laravel/framework[v5.4.36].
问题是我无法升级服务器,因为它将破坏其他站点。我如何解决它而不升级php版本。
答案 0 :(得分:2)
您可以使用platform
设置在所有环境中强制使用PHP 5.6软件包。在您的composer.json
中进行设置:
"config": {
"platform": {
"php": "5.6.37"
}
},
在您的开发环境上运行composer update
并提交新的composer.lock
-它应该只包含与PHP 5.6兼容的软件包,因此您应该能够在服务器上安装它。