【问题标题】:Updating PHP 5.6 to 7.0将 PHP 5.6 更新到 7.0
【发布时间】:2018-11-14 00:42:39
【问题描述】:

我从 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

Illuminate\Foundation\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 并启动服务。

【问题讨论】:

标签: php laravel


【解决方案1】:

您是否尝试过使用 brew?

$ brew unlink php56
$ brew install php70

记得重启apache...

【讨论】:

  • 他使用的是 MacOS 而不是 ubuntu/debian。
  • 这样他就可以使用brew了:brew unlink php56 brew install php70
  • 我尝试了 $brew unlink php56 但得到了这个错误 Error: No such keg: /usr/local/Cellar/php@5.
  • @Kyslik 啊,我明白了!那么你是有道理的;)哈哈,无论哪种方式都应该避免使用 OS X,但抛开个人意见,我会发表我的评论
【解决方案2】:

经过各种尝试解决此问题,以下是对我有用的步骤:

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

插入 export 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 OPcache v7.2.6,版权所有 (c) 1999-2018,由 Zend Technologies 提供

P.S:我注意到,当我检查我得到的答案所使用的版本时,

/usr/local/bin/php 

我不知道为什么会这样,但以防万一,请尝试使用 php --version 或 php -v

【讨论】:

    猜你喜欢
    • 2017-03-12
    • 2016-03-27
    • 2017-12-04
    • 2018-07-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-31
    • 2016-12-06
    相关资源
    最近更新 更多