用 composer 安装 redactor 时遇到的要求php版本7的问题

22 篇文章 0 订阅
2 篇文章 0 订阅

这两天才会使用 composer,以前不会用可能很大程度是因为 composer 访问国外的源速度慢的问题。
网站找到的方法,更换了源后好多了,具体办法不是本文讨论的内容。

安装 redactor,直接百度:yii2 redactor,应该是找到的第一条就是,用如下命令:

composer require --prefer-dist yiidoc/yii2-redactor "*"

这里有些问题需要说明一下:
1、这里用的是composer require而不是 php composer.phar require。
实际上这两个是执行的同样的命令,只不过前面的composer是一个.bat批处理,批处理里面引用的还是后面的命令。只不过用这个批处理,不光解决了当前目录不在php安装目录也能执行php.exe的问题,还解决了composer.phar不在当前目录的问题。
2、我用的yii2是basic版。执行这个composer命令要在和controller、models、view、web同级的目录下执行,因为这个文件夹里面包含composer.json文件。
对此我是这样理解的:上述composer命令在执行的时候是要安装 yiidoc/yii2-redactor,安装这个需要检查当前安装的位置是否已经有安装这个所需的基本文件,也就是在json里面列出来的。如果满足基本条件才会安装。如果在随便一个空目录执行这个命令是不会安装的。

执行命令后出现错误提示,没有安装下去:

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

  Problem 1
    - phpunit/phpunit 6.5.7 requires php ^7.0 -> your PHP version (5.5.12) does not satisfy that requirement.
    - phpunit/phpunit 6.5.7 requires php ^7.0 -> your PHP version (5.5.12) does not satisfy that requirement.
    - phpunit/phpunit 6.5.7 requires php ^7.0 -> your PHP version (5.5.12) does not satisfy that requirement.
    - Installation request for phpunit/phpunit (locked at 6.5.7) -> satisfiable by phpunit/phpunit[6.5.7].


Installation failed, reverting ./composer.json to its original content.

但是这时候我发现,虽然redactor没有安装,但是在composer.json文件中,需求里已经列出了redactor的内容。
于是我想是不是我可以不在命令里添加redactor,而直接运行

composer require

果然运行后没有再出需要php7的提示,而是好像进行了一些升级操作,删除了一些内容,又更新了删除的,另外把redactor也按上了。

D:\Work\Web\lffdc>composer require
Search for a package:
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 4 installs, 28 updates, 7 removals
  - Removing sebastian/object-reflector (1.1.1)
  - Removing theseer/tokenizer (1.1.0)
  - Removing sebastian/code-unit-reverse-lookup (1.0.1)
  - Removing phar-io/version (1.0.1)
  - Removing phar-io/manifest (1.0.1)
  - Removing sebastian/object-enumerator (3.0.3)
  - Removing sebastian/resource-operations (1.0.0)
  - Updating yiisoft/yii2-gii (2.0.6 => 2.0.7): Loading from cache
  - Updating sebastian/recursion-context (3.0.0 => 1.0.5): Loading from cache
  - Updating sebastian/exporter (3.1.0 => 1.2.2): Loading from cache
  - Updating phpunit/phpunit-mock-objects (5.0.6 => 2.3.8): Loading from cache
  - Updating codeception/stub (1.0.2 => 1.0.4): Loading from cache
  - Updating sebastian/diff (2.0.1 => 1.4.3): Loading from cache
  - Updating sebastian/comparator (2.1.3 => 1.2.4): Loading from cache
  - Updating phpdocumentor/type-resolver (0.4.0 => 0.3.0): Loading from cache
  - Updating phpdocumentor/reflection-docblock (4.3.0 => 3.2.2): Loading from cache
  - Updating phpspec/prophecy (1.7.5 => 1.7.6): Loading from cache
  - Updating myclabs/deep-copy (1.7.0 => 1.6.1): Loading from cache
  - Updating phpunit/php-token-stream (2.0.2 => 1.4.12): Loading from cache
  - Updating sebastian/version (2.0.1 => 1.0.6): Loading from cache
  - Updating sebastian/environment (3.1.0 => 1.3.8): Loading from cache
  - Updating phpunit/php-code-coverage (5.3.0 => 2.2.4): Loading from cache
  - Updating sebastian/global-state (2.0.0 => 1.1.1): Loading from cache
  - Installing symfony/polyfill-ctype (v1.8.0): Loading from cache
  - Updating symfony/yaml (v3.3.6 => v3.4.12): Loading from cache
  - Updating phpunit/phpunit (6.5.7 => 4.8.36): Loading from cache
  - Updating codeception/phpunit-wrapper (6.0.8 => 6.0.10): Loading from cache
  - Updating symfony/polyfill-mbstring (v1.7.0 => v1.8.0): Loading from cache
  - Updating symfony/dom-crawler (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/css-selector (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/browser-kit (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/event-dispatcher (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/debug (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/console (v3.3.6 => v3.4.12): Loading from cache
  - Updating symfony/finder (v3.3.6 => v3.4.12): Loading from cache
  - Updating codeception/base (2.4.0 => 2.4.1): Loading from cache
  - Installing ckeditor/ckeditor (4.7.3): Downloading (100%)
  - Installing 2amigos/yii2-ckeditor-widget (2.1.0): Downloading (100%)
  - Installing yiidoc/yii2-redactor (2.0.1): Loading from cache
Writing lock file
Generating autoload files

D:\Work\Web\lffdc>

到此,redactor安装成功。
安装后我发现,composer不光是下载了一些文件到不同的文件夹,同时也修改了本地的一些文件。
要么那么多玩php的人都推荐用composer安装php所需的一些插件呢!

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值