TP5.1 安装mongodb扩展 composer更新时报错的问题
更新时 提示 "topthink/think-installer" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.1.0")
订单系统所用扩展的topthink版本是 2.0.0 如果直接 composer update topthink/think-installer 扩展不兼容, 导致项目直接开不了.
处理
composer update topthink/think-installer --no-plugins
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 1 update, 0 removals
- Upgrading topthink/think-installer (v2.0.0 => v2.0.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 1 update, 1 removal
- Removing tecnickcom/tcpdf (6.3.0)
- Upgrading topthink/think-installer (v2.0.0 => v2.0.5): Extracting archive
- Installing topthink/framework (v5.1.39): Extracting archive
Generating autoload files
更新之后 版本没有直接升级到 2.1 而是上升到了 2.0.5
然后再安装mongodb扩展
composer require topthink/think-mongo=1.*
因为php版本是7.2 所以mongo只能是1.*版本的
./composer.json has been updated
Running composer update topthink/think-mongo
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking topthink/think-mongo (v1.8.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing topthink/think-mongo (v1.8.5): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class
安装成功
TP5的调用方法
database.php 配置文件添加
'mongodb' =>[
'type' =>'\think\mongo\Connection',
'query' =>'\think\mongo\Query',
'hostname' =>'192.168.x.x', //mongodb服务的IP地址
'database' =>'orderMongoDB',//mongodb的数据库名称
'username' =>'',
'password' =>'',
'hostport' =>'27017',//mongodb端口 默认
'dsn' =>'',
'params' =>[],
'charset' =>'utf8',
],
调用方法
Db::connect('mongodb')->name('表名')->select();
版权属于:BLOG DEWEBSTUDIO 本文作者:狒狒
原文地址: http://blog.dewebstudio.com/?post=114
版权声明:转载时必须以链接形式注明原始出处及本声明。
继续浏览:
发表评论