zoukankan      html  css  js  c++  java
  • 在Laravel外独立使用laravel-mongodb

    laravel框架外部使用laravel-mongodb 插件

    下载安装方式主要根据github上的参考:

    https://github.com/jenssegers/laravel-mongodb#installation

    参考一:

    安装

    Installation using composer:

    composer require jenssegers/mongodb
    Or
    composer require jenssegers/mongodb:*
     
    The service provider will register a mongodb database extension with the original database manager. There is no need to register additional facades or objects. When using mongodb connections, Laravel will automatically provide you with the corresponding mongodb objects.
    
    For usage outside Laravel, check out the Capsule manager and add:

    在Laravel外独立使用不需要注册,先预加载Capsule manager,然后添加如下代码 $capsule
    ->getDatabaseManager()->extend('mongodb', function($config) { return new JenssegersMongodbConnection($config); });

    ###该段代码不添加会报错: Uncaught exception 'InvalidArgumentException' with message 'Unsupported driver [mongodb]' 

    安装后可能会出现问题:
    Fatal error: Class 'MongoClient' not found

    这个是因为composer安装后有mongo,mongodb,就是laravel-mongodb 支持2个都支持,php 也同时支持mongo,mongodb
    详见:http://php.net/MongoClient
    如果确认你安转了 mongodb

        检测方法:
        cli;
        php -m | grep mongo
        php -i | grep 'Mongo'

    检测/vendor/composer/install.json

    mongo 去掉,composer update ,composer install 搞定

    
    
     


  • 相关阅读:
    Handler机制来处理子线程去更新UI线程控件
    获得某月份的天数
    listview选中没有效果
    kali或其他系统,虚拟机中不能加载镜像
    tomcat开启多个端口
    kali自定义分辨率
    Redis 安装手册
    bash检查centos服务器运行状态
    关于利用RD client远程电脑,和输入法的一些问题
    centOS下 MYSQL基本操作
  • 原文地址:https://www.cnblogs.com/cbugs/p/10081461.html
Copyright © 2011-2022 走看看