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 搞定

    
    
     


  • 相关阅读:
    iOS应用程序生命周期(前后台切换,应用的各种状态)详解
    Urlrewrite
    下载文件、根据链接生成二维码
    三级联动
    easy-ui的datagrid
    $.extend、$.fn.extend
    windows.open、 window.location.href
    JS小整理
    Jsp数字格式化
    同时执行多个$.getJSON() 出现数据混乱的问题的解决
  • 原文地址:https://www.cnblogs.com/cbugs/p/10081461.html
Copyright © 2011-2022 走看看