将PHP 5.6更新为7.0

时间:2018-06-04 16:05:01

标签: php laravel

我从Git中提取了一个现有的Laravel项目并创建了缺少的.env文件。当我运行作曲家安装时,错误消息

    Your requirements could not be resolved to an installable set of packages.

Problem 1
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.36 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.5 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.3 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.28 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.2 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.
- illuminate/support v5.6.27 requires php >=7.0 -> your PHP version (5.6.32) does not satisfy that requirement.

之后我安装PHP 7.0版本。我试图用PHP命令检查更改,但它仍然表明PHP 5.6.27。 我运行的composer install安装到某个点,但结束时出现以下建议和错误

- Installing phpunit/phpunit (6.5.8): Downloading (100%)         
symfony/var-dumper suggests installing ext-symfony_debug ()
symfony/routing suggests installing doctrine/annotations (For using the annotation loader)
symfony/routing suggests installing symfony/config (For using the all-in-one router or any loader)
symfony/routing suggests installing symfony/dependency-injection (For loading routes from a service)
symfony/routing suggests installing symfony/expression-language (For using expression matching)
symfony/routing suggests installing symfony/yaml (For using the YAML loader)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
symfony/event-dispatcher suggests installing symfony/dependency-injection ()
symfony/http-kernel suggests installing symfony/browser-kit ()
symfony/http-kernel suggests installing symfony/class-loader ()
symfony/http-kernel suggests installing symfony/config ()
symfony/http-kernel suggests installing symfony/dependency-injection ()
symfony/console suggests installing symfony/filesystem ()
ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)
ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
ramsey/uuid suggests installing moontoast/math (Provides support for converting UUID to 128-bit integer (in string form).)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of           Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
symfony/translation suggests installing symfony/config ()
symfony/translation suggests installing symfony/yaml ()
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
league/flysystem suggests installing league/flysystem-aws-s3-v2 (Allows you to use S3 storage with AWS SDK v2)
league/flysystem suggests installing league/flysystem-aws-s3-v3 (Allows you to use S3 storage with AWS SDK v3)
league/flysystem suggests installing league/flysystem-azure (Allows you to use Windows Azure Blob storage)
 league/flysystem suggests installing league/flysystem-cached-adapter (Flysystem adapter decorator for metadata caching)
league/flysystem suggests installing league/flysystem-eventable-filesystem (Allows you to use EventableFilesystem)
league/flysystem suggests installing league/flysystem-rackspace (Allows you to use Rackspace Cloud Files)
league/flysystem suggests installing league/flysystem-sftp (Allows you to use SFTP server storage via phpseclib)
league/flysystem suggests installing league/flysystem-webdav (Allows you to use WebDAV storage)
league/flysystem suggests installing league/flysystem-ziparchive (Allows you to use ZipArchive adapter)
league/flysystem suggests installing spatie/flysystem-dropbox (Allows you to use Dropbox storage)
league/flysystem suggests installing srmklive/flysystem-dropbox-v2 (Allows you to use Dropbox storage for PHP 5 applications)
laravel/framework suggests installing aws/aws-sdk-php (Required to use the SQS queue driver and SES mail driver (~3.0).)
laravel/framework suggests installing doctrine/dbal (Required to rename columns and drop SQLite columns (~2.5).)
laravel/framework suggests installing ext-pcntl (Required to use all features of the queue worker.)
laravel/framework suggests installing guzzlehttp/guzzle (Required to use the Mailgun and Mandrill mail drivers and the ping methods on schedules (~6.0).)
laravel/framework suggests installing league/flysystem-aws-s3-v3 (Required to use the Flysystem S3 driver (~1.0).)
laravel/framework suggests installing league/flysystem-cached-adapter (Required to use Flysystem caching (~1.0).)
laravel/framework suggests installing league/flysystem-rackspace (Required to use the Flysystem Rackspace driver (~1.0).)
laravel/framework suggests installing nexmo/client (Required to use the Nexmo transport (~1.0).)
laravel/framework suggests installing pda/pheanstalk (Required to use the beanstalk queue driver (~3.0).)
laravel/framework suggests installing predis/predis (Required to use the redis cache and queue drivers (~1.0).)
laravel/framework suggests installing pusher/pusher-php-server (Required to use the Pusher broadcast driver (~3.0).)
laravel/framework suggests installing symfony/dom-crawler (Required to use most of the crawler integration testing tools (~3.3).)
laravel/framework suggests installing symfony/psr-http-message-bridge (Required to psr7 bridging features (~1.0).)
intervention/image suggests installing ext-imagick (to use Imagick based image processing.)
intervention/image suggests installing intervention/imagecache (Caching extension for the Intervention Image library)
psy/psysh suggests installing ext-pcntl (Enabling the PCNTL extension makes PsySH a lot happier :))
psy/psysh suggests installing ext-pdo-sqlite (The doc command requires SQLite to work.)
psy/psysh suggests installing hoa/console (A pure PHP readline implementation.     You'll want this if your PHP install doesn't already support readline or libedit.)
filp/whoops suggests installing whoops/soap (Formats errors as SOAP responses)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
Writing lock file
Generating optimized autoload files
  

照亮\基金会\ ComposerScripts :: postAutoloadDump

Parse error: syntax error, unexpected '?' in /Applications/MAMP/htdocs/folder/projectname/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php on line 233

我已安装PHP 7.0,但该版本尚未更改。 PHP 7是必需的版本。我该怎么切换?我在Mac上使用Laravel

我该如何解决这个问题?我需要设置生成APP_Key并启动服务。

2 个答案:

答案 0 :(得分:0)

你尝试过使用brew吗?

$ brew unlink php56
$ brew install php70

记得重启apache ......

答案 1 :(得分:0)

在尝试解决此问题后,以下是对我有用的步骤:

brew install brew tap homebrew/dupes

显示"警告:自制/核心是浅层克隆。"为了解决这个问题,我跑了

git -C "$(brew --repo homebrew/core)" fetch --unshallow

然后

brew install brew-php-switcher

以上命令安装了brew-php-switcher依赖项以及php版本7.2.6。正在运行

vim ~/.bash_profile

插入导出PATH = / Applications / MAMP / bin / php / php7.2.6 / bin:$ PATH

使用" php -v"

检查我的php版本

PHP 7.2.6(cli)(建于:2018年6月5日10:09:45)(NTS) 版权所有(c)1997-2018 PHP小组 Zend Engine v3.2.0,版权所有(c)1998-2018 Zend Technologies     Zend Technologies的Zend OPcache v7.2.6,Copyright(c)1999-2018,

P.S:我注意到当我检查我得到的答案的版本是

/usr/local/bin/php 

我不知道为什么会这样,但万一遇到这种情况,请尝试使用php --version或php -v