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

    
    
     


  • 相关阅读:
    java中调用kettle转换文件
    开源游戏引擎体验
    cocos2d-x 托付模式的巧妙运用——附源代码(二)
    BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 Windows Phone
    redis String结构
    Redis 键命令
    Redis 基础命令
    linux curl 命令的使用
    将spring boot项目部署到tomcat容器中
    Redis常用命令
  • 原文地址:https://www.cnblogs.com/cbugs/p/10081461.html
Copyright © 2011-2022 走看看