Download the PHP package zrone/hyperf-mongodb without Composer

On this page you can find all versions of the php package zrone/hyperf-mongodb. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package hyperf-mongodb

默认使用mongodb提供的库来封装,官方git地址:https://github.com/mongodb/mongo-php-library

1、支持类似mysql orm的一些操作

2、支持迁移文件

3、只支持hyperf框架,由于swoole协程不支持mongodb,所以所有的方法都采用task进程来实现,该包已经封装好所有的方法都会投递到task进程进行操作,task进程建议开启多一点

4、该包默认使用了连接池

使用

1、拉取包

2、发布配置

3、配置介绍

4、生成迁移文件

上面的命令会自动生成一个迁移文件,会生成一个文件到配置文件指定的迁移目录中

5、迁移文件例子

6、迁移命令

上面这个命令会迁移你所有生成的文件,迁移文件路径在配置文件里面配置

7、开发使用

1、上面能像orm一样能进行迁移了,解决了升级的问题,下面我们来说一下开发时候怎么使用
2、在你的项目里面新建一个目录,该目录叫mongo(自行命名,类似orm的model)
3、比如我现在项目里面有一个库,叫test,test里面有两个collection,名字为co1,co2(你把它当成mysql的表一样)
4、我在mongo目录新建两个文件,叫Co1Mongo和Co2Mongo,都继承\Zrone\MongoDb\MongoDb

5、查询co1中的一条数据

6、支持有多种方法,详细你可以到Zrone\MongoDb\MongoDb查看,或者你可以去看官方的php-mongodb文档,https://docs.mongodb.com/php-library/v1.5/reference/method/MongoDBCollection-createIndexes/

8、结束

如果你有使用的问题或者建议,欢迎你提一个isset,由于太匆忙,等我开发完现在的项目,我会重新优化和迭代这个包,如果开发中有遇到问题或者有更好的写法,我会迭代到这个包这里。

9、注意

如果你使用的是mongodb默认生成_id,那么更新和删除我默认已经帮你使用MongoDB\BSON\ObjectId进行了转换,所以你无需再转换,你直接把_id对应的字符串传进去就好了,比如要根据_id获取某条数据,$filter=['_id' => 'xxxxxx']即可。获取数据时,我也默认帮你把_id转成了字符串

10、遇到问题

1、因为我使用了hyperf框架,所以基本都是单例模式。我model里面使用\Zrone\MongoDb\MongoDb 的setCollectionName方法来切换表时,必须处理完逻辑后然后再切回原始的collectionName,否则你查询的会是你切换的表


All versions of hyperf-mongodb with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
psr/container Version ^1.0|^2.0
mongodb/mongodb Version ^1.17.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zrone/hyperf-mongodb contains the following files

Loading the files please wait ....