Homestead安装完成,git克隆下来的项目不能运行composer install和php artisan命令

不改需求的程序猿
  • 18

运行composer install报错如下

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - This package requires php ^7.1.3 but your PHP version (7.0.1) does not satisfy that requirement.
  Problem 2
    - Installation request for chillerlan/php-qrcode 2.0.6 -> satisfiable by chillerlan/php-qrcode[2.0.6].
    - chillerlan/php-qrcode 2.0.6 requires php >=7.0.3 -> your PHP version (7.0.1) does not satisfy that requirement.
  Problem 3
    - Installation request for chillerlan/php-traits 1.1.13 -> satisfiable by chillerlan/php-traits[1.1.13].
    - chillerlan/php-traits 1.1.13 requires php >=7.0.3 -> your PHP version (7.0.1) does not satisfy that requirement.
  Problem 4
    - Installation request for laravel/framework v5.7.5 -> satisfiable by laravel/framework[v5.7.5].
    - laravel/framework v5.7.5 requires php ^7.1.3 -> your PHP version (7.0.1) does not satisfy that requirement.
  Problem 5
    - Installation request for laravel/horizon v1.4.0 -> satisfiable by laravel/horizon[v1.4.0].
    - laravel/horizon v1.4.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system.
  Problem 6
    - Installation request for symfony/cache v4.1.4 -> satisfiable by symfony/cache[v4.1.4].
    - symfony/cache v4.1.4 requires php ^7.1.3 -> your PHP version (7.0.1) does not satisfy that requirement.
  Problem 7
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.1) does not satisfy that requirement.
    - doctrine/inflector v1.3.0 requires php ^7.1 -> your PHP version (7.0.1) does not satisfy that requirement.
    - Installation request for doctrine/inflector v1.3.0 -> satisfiable by doctrine/inflector[v1.3.0].

  To enable extensions, verify that they are enabled in your .ini files:
    - D:\PHPWAMP_IN2\phpwamp\server\php-7.0.1\php.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

运行php artisan make:controller TestController报错如下

PHP Parse error:  syntax error, unexpected '?', expecting variable (T_VARIABLE) in D
:\code\tiyu\vendor\symfony\console\Output\Output.php on line 40

Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE) in D:\cod
e\tiyu\vendor\symfony\console\Output\Output.php on line 40

然后尝试删除那个问号,报错如下

PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Output\is_iterable() in D:\code\tiyu\vendor\symfony\console\Output\Output.php:140
Stack trace:
#0 D:\code\tiyu\vendor\symfony\console\Output\Output.php(132): Symfony\Component\Console\Output\Output->write('', true, 16)
#1 D:\code\tiyu\vendor\symfony\console\Application.php(741): Symfony\Component\Console\Output\Output->writeln('', 16)
#2 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(469): Symfony\Component\Console\Application->renderException(Object(Symfony\Component\Debug\Exception\Fatal
ThrowableError), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(101): Illuminate\Foundation\Exceptions\Handler->renderForConsole(Object(Symfony\Component\Console\O
utput\ConsoleOutput), Object(Symfony\Component\Debug\Exception\FatalThrowableError))
#4 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation in D:\code\tiyu\vendor\symfony\console\Output\Output.php on line 140
PHP Fatal error:  Uncaught Error: Call to undefined function Symfony\Component\Console\Output\is_iterable() in D:\code\tiyu\vendor\symfony\console\Output\Output.php:140
Stack trace:
#0 D:\code\tiyu\vendor\symfony\console\Output\Output.php(132): Symfony\Component\Console\Output\Output->write('', true, 16)
#1 D:\code\tiyu\vendor\symfony\console\Application.php(741): Symfony\Component\Console\Output\Output->writeln('', 16)
#2 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation\Exceptions\Handler.php(469): Symfony\Component\Console\Application->renderException(Object(Symfony\Component\Debug\Exception\Fatal
ErrorException), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\HandleExceptions.php(101): Illuminate\Foundation\Exceptions\Handler->renderForConsole(Object(Symfony\Component\Console\O
utput\ConsoleOutput), Object(Symfony\Component\Debug\Exception\FatalErrorException))
#4 D:\code\tiyu\vendor\laravel\framework\src\Illuminate\Foundation in D:\code\tiyu\vendor\symfony\console\Output\Output.php on line 140
回复
阅读 3.1k
3 个回答

它要求 php 7.1.3 至少,而你的环境只有 7.0.1
它还要求 ext-pcntl 扩展而你没有开

1楼说的没错,你的php版本不对。不过我奇怪的是,你说你装好了homestead,homestead里面的php版本是7.1的,不应该出现你所说的问题的

已经解决了,谢谢大家了

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏